diff options
author | Benji Dial <benji6283@gmail.com> | 2021-03-07 23:19:48 -0500 |
---|---|---|
committer | Benji Dial <benji6283@gmail.com> | 2021-03-07 23:19:48 -0500 |
commit | 1a5ece4f52ef17c7c868e95eb26e98137d5cab6f (patch) | |
tree | 2ab5c639d368d3ec497b464009f0401e71d433f1 /src/user/raleigh/window.cpp | |
parent | 348e1876d25320e6480f2795c9388b2bc080c743 (diff) | |
download | portland-os-1a5ece4f52ef17c7c868e95eb26e98137d5cab6f.tar.gz |
keyboard support in raleigh, word wrap and more in entry widget
Diffstat (limited to 'src/user/raleigh/window.cpp')
-rw-r--r-- | src/user/raleigh/window.cpp | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/user/raleigh/window.cpp b/src/user/raleigh/window.cpp index c23545b..052422e 100644 --- a/src/user/raleigh/window.cpp +++ b/src/user/raleigh/window.cpp @@ -7,8 +7,8 @@ namespace raleigh { window::window(widget &root, _pixel_t bg_color, bool (*on_close)(window &)) - : handle(0), size(root.size), root(root), bg_color(bg_color), - needs_repaint(false), on_close(on_close) { + : handle(0), size(root.size), root(root), focussed(&root), + bg_color(bg_color), on_close(on_close) { root.w = this; root.window_offset = coord(0, 0); root.notify_window_change(); @@ -18,6 +18,8 @@ namespace raleigh { show_error_and_quitf("Failed to create %d byte pixel buffer\nfor requested %dx%d pixel window.", size.x * size.y * sizeof(_pixel_t), size.x, size.y); paint_full(); + root.on_focus(); + needs_repaint = false; } window::try_actions_return_t window::try_actions() { @@ -39,9 +41,15 @@ namespace raleigh { return DELETE; got = GOOD; if (wa.action_type == wa.MOUSE_DOWN) - root.try_handle_click(coord(wa.as_mouse.x, wa.as_mouse.y), wa.as_mouse.which, false); - if (wa.action_type == wa.MOUSE_UP) - root.try_handle_click(coord(wa.as_mouse.x, wa.as_mouse.y), wa.as_mouse.which, true); + root.handle_click(coord(wa.as_mouse.x, wa.as_mouse.y), wa.as_mouse.which, false); + else if (wa.action_type == wa.MOUSE_UP) + root.handle_click(coord(wa.as_mouse.x, wa.as_mouse.y), wa.as_mouse.which, true); + else if (wa.action_type == wa.KEY_DOWN) + focussed->handle_key(wa.as_key); + else if (wa.action_type == wa.FOCUS_ENTER) + focussed->on_focus(); + else if (wa.action_type == wa.FOCUS_LEAVE) + focussed->on_unfocus(); } } @@ -67,4 +75,12 @@ namespace raleigh { show_error_and_quitf("Failed to get window handle for requested window."); open_windows.add_front(*this); } + + void window::focus(widget &w) { + if (focussed != &w) { + focussed->on_unfocus(); + focussed = &w; + focussed->on_focus(); + } + } }
\ No newline at end of file |