92 rebuild_focus_if_needed();
100 if (mouse.change.x != 0.0F || mouse.change.y != 0.0F) {
102 if (
Widget* new_hover = hit_test(root, mouse.position); new_hover != ctx.hover) {
103 if (ctx.hover !=
nullptr) {
105 .pointer_pos = mouse.position };
106 ctx.hover->on_event(ctx, leave);
108 ctx.hover = new_hover;
109 if (ctx.hover !=
nullptr) {
111 .pointer_pos = mouse.position };
112 ctx.hover->on_event(ctx, enter);
119 ctx.theme.show_focus =
false;
125 if (get_mouse_button_down(MouseButton::Left) || get_mouse_button_down(MouseButton::Right)
126 || get_mouse_button_down(MouseButton::Middle)) {
128 .pointer_pos = mouse.position,
129 .mouse_button = MouseButton::Left };
131 ctx.theme.show_focus =
false;
135 if (get_mouse_button_up(MouseButton::Left) || get_mouse_button_up(MouseButton::Right)
136 || get_mouse_button_up(MouseButton::Middle)) {
138 .pointer_pos = mouse.position,
139 .mouse_button = MouseButton::Left };
141 ctx.theme.show_focus =
false;
147 dispatch_to_focused(ti);
151 const auto shift = get_key(Key::LShift) || get_key(Key::RShift);
154 if (get_key_down(Key::Tab)) {
156 ctx.focus.focus_prev(ctx);
158 ctx.focus.focus_next(ctx);
161 ctx.theme.show_focus =
true;
165 if (get_key_down(Key::Up)) {
167 if (!dispatch_to_focused(e)) {
168 ctx.focus.focus_dir(ctx, 0, -1);
169 ctx.theme.show_focus =
true;
172 if (get_key_down(Key::Down)) {
174 if (!dispatch_to_focused(e)) {
175 ctx.focus.focus_dir(ctx, 0, +1);
176 ctx.theme.show_focus =
true;
179 if (get_key_down(Key::Left)) {
181 if (!dispatch_to_focused(e)) {
182 ctx.focus.focus_dir(ctx, -1, 0);
183 ctx.theme.show_focus =
true;
186 if (get_key_down(Key::Right)) {
188 if (!dispatch_to_focused(e)) {
189 ctx.focus.focus_dir(ctx, +1, 0);
190 ctx.theme.show_focus =
true;
195 if (get_key_down(Key::Backspace)) {
197 dispatch_to_focused(e);
199 if (get_key_down(Key::Delete)) {
201 dispatch_to_focused(e);
203 if (get_key_down(Key::Home)) {
205 dispatch_to_focused(e);
207 if (get_key_down(Key::End)) {
209 dispatch_to_focused(e);
213 if (get_key_down(Key::Return) || get_key_down(Key::Space)) {
215 dispatch_to_focused(a);
217 if (get_key_down(Key::Escape)) {
219 dispatch_to_focused(b);