TermOx
focus.hpp
1 #ifndef TERMOX_SYSTEM_DETAIL_FOCUS_HPP
2 #define TERMOX_SYSTEM_DETAIL_FOCUS_HPP
3 
4 namespace ox {
5 class Widget;
6 } // namespace ox
7 
8 namespace ox::detail {
9 
10 class Focus {
11  public:
13  [[nodiscard]] static auto focus_widget() -> ox::Widget*;
14 
16  static void mouse_press(ox::Widget& clicked);
17 
19  static auto tab_press() -> bool;
20 
22  static auto shift_tab_press() -> bool;
23 
25 
26  static void set(ox::Widget& new_focus);
27 
29  static void clear();
30 
32 
33  static void clear_without_posting_event();
34 
36  static void enable_tab_focus();
37 
39  static void disable_tab_focus();
40 
42  static void suppress_tab();
43 
45  static void unsuppress_tab();
46 
47  private:
48  static ox::Widget* focus_widget_;
49  static bool tab_enabled_;
50  static bool tab_suppressed_;
51 };
52 
53 } // namespace ox::detail
54 #endif // TERMOX_SYSTEM_DETAIL_FOCUS_HPP
Definition: widget.hpp:31
Definition: focus.hpp:10
static void mouse_press(ox::Widget &clicked)
Sets the focus to clicked if it has a Focus_policy::Mouse/Strong.
Definition: focus.cpp:79
static void disable_tab_focus()
Disable Tab/Back_tab keys from changing focus Widget.
Definition: focus.cpp:141
static void suppress_tab()
Stops a Tab or Back_tab from changing focus to the next Widget.
Definition: focus.cpp:143
static void enable_tab_focus()
Enable Tab/Back_tab keys to change the focus Widget.
Definition: focus.cpp:139
static void clear_without_posting_event()
Set the focus widget to nullptr and do not send a Focus_out_event.
Definition: focus.cpp:137
static auto tab_press() -> bool
Find the next Focus_policy::Tab/Strong Widget and set focus to it.
Definition: focus.cpp:87
static void set(ox::Widget &new_focus)
Sets focus to new_focus, via a posted Focus_in event.
Definition: focus.cpp:115
static void unsuppress_tab()
Re-enable a Tab or Back_tab to change focus to the next Widget.
Definition: focus.cpp:145
static void clear()
Set the focus widget to nullptr and send Focus_out_event to focus_widg.
Definition: focus.cpp:129
static auto focus_widget() -> ox::Widget *
Return a pointer to the currently focused Widget, can return nullptr.
Definition: focus.cpp:77
static auto shift_tab_press() -> bool
Find the previous Focus_policy::Tab/Strong Widget and set focus to it.
Definition: focus.cpp:101