mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
More work on focus.
ListBox now renders differently depending on focus state.
This commit is contained in:
parent
1929cb6b71
commit
6f1b384cde
6 changed files with 39 additions and 9 deletions
|
@ -49,6 +49,10 @@ void Widget::event(Event& event)
|
|||
case Event::MouseMove:
|
||||
return onMouseMove(static_cast<MouseEvent&>(event));
|
||||
case Event::MouseDown:
|
||||
if (auto* win = window()) {
|
||||
// FIXME: if (acceptsFocus())
|
||||
win->setFocusedWidget(this);
|
||||
}
|
||||
return onMouseDown(static_cast<MouseEvent&>(event));
|
||||
case Event::MouseUp:
|
||||
return onMouseUp(static_cast<MouseEvent&>(event));
|
||||
|
@ -123,13 +127,15 @@ void Widget::setWindow(Window* window)
|
|||
|
||||
bool Widget::isFocused() const
|
||||
{
|
||||
return m_window && m_window->focusedWidget() == this;
|
||||
if (auto* win = window())
|
||||
return win->isActive() && win->focusedWidget() == this;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Widget::setFocus(bool focus)
|
||||
{
|
||||
if (focus == isFocused())
|
||||
return;
|
||||
if (m_window)
|
||||
m_window->setFocusedWidget(this);
|
||||
if (auto* win = window())
|
||||
win->setFocusedWidget(this);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue