mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-15 18:06:46 +00:00
Add event handling for key presses for navigating a menu. The currently hovered menu item is tracked through an index which is either incremented or decremented on up or down arrow key presses, changing the hovered item. Whenever there is a mouse move event, we ensure that the current index matches the currently hovered item so that the mouse and keyboard do not get out of sync. If the right key is pressed, and we are on a submenu menu item, we 'enter' that submenu. While we are currently in a submenu, we forward all keypress events to that submenu for handling. This allows us to traverse the heirachy of a menu. While in a submenu, if the left key is pressed, we leave that submenu and start handling the keypresses ourselves again. There is currently a small issue where the mouse hover and key hover can get out of sync. The mouse can be traversing a submenu, but the parent menu has no idea that the mouse has 'entered' a submenu, so will handle the key presses itself, instead of forwarding them to the submenu. One potential fix for this is for a menu to tell its menu parent that the submenu is being traversed.
16 KiB
16 KiB