1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 22:48:11 +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

@ -58,11 +58,8 @@ public:
void set_action(Action&);
virtual bool accepts_focus() const override { return m_focusable; }
virtual bool is_uncheckable() const override;
void set_focusable(bool b) { m_focusable = b; }
protected:
explicit Button(const StringView& text = {});
virtual void paint_event(PaintEvent&) override;
@ -72,7 +69,6 @@ private:
Gfx::ButtonStyle m_button_style { Gfx::ButtonStyle::Normal };
Gfx::TextAlignment m_text_alignment { Gfx::TextAlignment::Center };
WeakPtr<Action> m_action;
bool m_focusable { true };
};
}