mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 03:47:35 +00:00
Implement basic focus.
This commit is contained in:
parent
44a32039be
commit
1929cb6b71
6 changed files with 45 additions and 4 deletions
|
@ -83,6 +83,12 @@ void Window::event(Event& event)
|
|||
return Object::event(event);
|
||||
}
|
||||
|
||||
if (event.isKeyEvent()) {
|
||||
if (m_focusedWidget)
|
||||
return m_focusedWidget->event(event);
|
||||
return Object::event(event);
|
||||
}
|
||||
|
||||
return Object::event(event);
|
||||
}
|
||||
|
||||
|
@ -91,3 +97,14 @@ bool Window::isActive() const
|
|||
return WindowManager::the().activeWindow() == this;
|
||||
}
|
||||
|
||||
void Window::setFocusedWidget(Widget* widget)
|
||||
{
|
||||
if (m_focusedWidget.ptr() == widget)
|
||||
return;
|
||||
if (!widget) {
|
||||
m_focusedWidget = nullptr;
|
||||
return;
|
||||
}
|
||||
m_focusedWidget = widget->makeWeakPtr();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue