mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:37:46 +00:00
LibGUI: Focus the first focusable widget added to a window
It feels really awkward if nothing is focused when opening a window.
This commit is contained in:
parent
65d94a1e74
commit
4806cd122d
3 changed files with 11 additions and 2 deletions
|
@ -115,6 +115,8 @@ void Widget::child_event(Core::ChildEvent& event)
|
||||||
else
|
else
|
||||||
layout()->add_widget(Core::to<Widget>(*event.child()));
|
layout()->add_widget(Core::to<Widget>(*event.child()));
|
||||||
}
|
}
|
||||||
|
if (window() && event.child() && Core::is<Widget>(*event.child()))
|
||||||
|
window()->did_add_widget({}, Core::to<Widget>(*event.child()));
|
||||||
}
|
}
|
||||||
if (event.type() == Event::ChildRemoved) {
|
if (event.type() == Event::ChildRemoved) {
|
||||||
if (layout()) {
|
if (layout()) {
|
||||||
|
|
|
@ -761,7 +761,13 @@ void Window::set_size_increment(const Gfx::Size& size_increment)
|
||||||
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement>(m_window_id, m_base_size, m_size_increment);
|
WindowServerConnection::the().send_sync<Messages::WindowServer::SetWindowBaseSizeAndSizeIncrement>(m_window_id, m_base_size, m_size_increment);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::did_remove_widget(Badge<Widget>, const Widget& widget)
|
void Window::did_add_widget(Badge<Widget>, Widget& widget)
|
||||||
|
{
|
||||||
|
if (!m_focused_widget && widget.accepts_focus())
|
||||||
|
set_focused_widget(&widget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::did_remove_widget(Badge<Widget>, Widget& widget)
|
||||||
{
|
{
|
||||||
if (m_focused_widget == &widget)
|
if (m_focused_widget == &widget)
|
||||||
m_focused_widget = nullptr;
|
m_focused_widget = nullptr;
|
||||||
|
|
|
@ -183,7 +183,8 @@ public:
|
||||||
|
|
||||||
Action* action_for_key_event(const KeyEvent&);
|
Action* action_for_key_event(const KeyEvent&);
|
||||||
|
|
||||||
void did_remove_widget(Badge<Widget>, const Widget&);
|
void did_add_widget(Badge<Widget>, Widget&);
|
||||||
|
void did_remove_widget(Badge<Widget>, Widget&);
|
||||||
|
|
||||||
Window* find_parent_window();
|
Window* find_parent_window();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue