mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-24 23:23:58 +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
Notes:
sideshowbarker
2024-07-19 06:16:56 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/4806cd122d3
3 changed files with 11 additions and 2 deletions
|
@ -115,6 +115,8 @@ void Widget::child_event(Core::ChildEvent& event)
|
|||
else
|
||||
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 (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);
|
||||
}
|
||||
|
||||
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)
|
||||
m_focused_widget = nullptr;
|
||||
|
|
|
@ -183,7 +183,8 @@ public:
|
|||
|
||||
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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue