92 rebuild_focus_if_needed();
98 const auto& mouse = get_mouse();
101 if (mouse.change.x != 0.0F || mouse.change.y != 0.0F) {
103 if (
Widget* new_hover = hit_test(root, mouse.position); new_hover != ctx.hover) {
104 if (ctx.hover !=
nullptr) {
106 .pointer_pos = mouse.position };
107 ctx.hover->on_event(ctx, leave);
109 ctx.hover = new_hover;
110 if (ctx.hover !=
nullptr) {
112 .pointer_pos = mouse.position };
113 ctx.hover->on_event(ctx, enter);
120 ctx.theme.show_focus =
false;
126 if (get_mouse_button_down(MouseButton::Left) || get_mouse_button_down(MouseButton::Right)
127 || get_mouse_button_down(MouseButton::Middle)) {
129 .pointer_pos = mouse.position,
130 .mouse_button = MouseButton::Left };
132 ctx.theme.show_focus =
false;
136 if (get_mouse_button_up(MouseButton::Left) || get_mouse_button_up(MouseButton::Right)
137 || get_mouse_button_up(MouseButton::Middle)) {
139 .pointer_pos = mouse.position,
140 .mouse_button = MouseButton::Left };
142 ctx.theme.show_focus =
false;
148 dispatch_to_focused(ti);
152 const auto shift = get_key(Key::LShift) || get_key(Key::RShift);
155 if (get_key_down(Key::Tab)) {
157 ctx.focus.focus_prev(ctx);
159 ctx.focus.focus_next(ctx);
162 ctx.theme.show_focus =
true;
166 if (get_key_down(Key::Up)) {
168 if (!dispatch_to_focused(e)) {
169 ctx.focus.focus_dir(ctx, 0, -1);
170 ctx.theme.show_focus =
true;
173 if (get_key_down(Key::Down)) {
175 if (!dispatch_to_focused(e)) {
176 ctx.focus.focus_dir(ctx, 0, +1);
177 ctx.theme.show_focus =
true;
180 if (get_key_down(Key::Left)) {
182 if (!dispatch_to_focused(e)) {
183 ctx.focus.focus_dir(ctx, -1, 0);
184 ctx.theme.show_focus =
true;
187 if (get_key_down(Key::Right)) {
189 if (!dispatch_to_focused(e)) {
190 ctx.focus.focus_dir(ctx, +1, 0);
191 ctx.theme.show_focus =
true;
196 if (get_key_down(Key::Backspace)) {
198 dispatch_to_focused(e);
200 if (get_key_down(Key::Delete)) {
202 dispatch_to_focused(e);
204 if (get_key_down(Key::Home)) {
206 dispatch_to_focused(e);
208 if (get_key_down(Key::End)) {
210 dispatch_to_focused(e);
214 if (get_key_down(Key::Return) || get_key_down(Key::Space)) {
216 dispatch_to_focused(a);
218 if (get_key_down(Key::Escape)) {
220 dispatch_to_focused(b);