1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 04:47:34 +00:00

LibGUI: Add Widget focus policies

Every widget now has a GUI::FocusPolicy that determines how it can
receive focus:

- NoFocus: The widget is not focusable (default)
- TabFocus: The widget can be focused using the tab key.
- ClickFocus: The widget can be focused by clicking on it.
- StrongFocus: Both of the above.

For widgets that have a focus proxy, getting/setting the focus policy
will affect the proxy instead.
This commit is contained in:
Andreas Kling 2020-10-30 10:58:27 +01:00
parent 34014fa838
commit aef56159a8
32 changed files with 64 additions and 40 deletions

View file

@ -109,6 +109,8 @@ ConsoleWidget::ConsoleWidget()
print_html(JS::MarkupGenerator::html_from_value(m_interpreter->vm().last_value()));
};
set_focus_proxy(m_input);
auto& clear_button = bottom_container.add<GUI::Button>();
clear_button.set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fixed);
clear_button.set_preferred_size(22, 22);
@ -165,8 +167,4 @@ void ConsoleWidget::clear_output()
m_output_view->update();
}
void ConsoleWidget::focusin_event(GUI::FocusEvent&)
{
m_input->set_focus(true);
}
}