Closed magreenblatt closed 7 years ago
Attached focused_menu.png is an example of what the focused CefMenuButton with accelerator and mnemonic (underlined) characters looks like.
Some notes on relevant code paths in Chromium:
It should be sufficient to handle key events at the window level for focus-related changes. We might in the future expose an unhandled key event callback at the control (CefView) level if necessary.
Done in master revision bd1b801 (bb) and 2987 branch revision e31a44a (bb).
Master revision 6ed4fe9 (bb) and 2987 branch revision 368273c (bb) adds groups (associated controls that support focus traversal with arrow keys) and focus/blur callbacks.
--show-top-menu
command-line flag.Master revision 6eaf11f (bb) and 2987 branch revision 874e670 (bb) add support for top menu switching using mouse and arrow keys.
--hide-top-menu
to hide it).Master revision 16125bd (bb) and 2987 branch revision b0c8a34 (bb) add support for mnemonic (underlined) characters in MenuButton labels.
Support ink drop effect on buttons in master revision 10f9a94 (bb) and 2987 branch revision d6eff7d (bb). Fix layout calculation for LabelButton with mnemonics in master revision b08f0ed (bb) and 2987 branch revision 68b0352 (bb). Support styling of menus in master revision 8fa8af3 (bb) and 2987 branch revision c2a87c8 (bb).
--use-views --background-color=black
command-line flags to see the result of menu styling.
Original report by me.
There are a few parts to this:
1. Support registration of accelerators with CefWindow and delivery via CefWindowDelegate.
A. Triggered accelerators will be delivered to the focused window first.
B. For CefBrowserView allow configuration of whether the CefBrowser gets an opportunity to handle the accelerator key event.
2. Support CefMenuButton focus and keyboard navigation.
A. Accelerators can be displayed in the menu using the existing CefMenuModel::SetAcceleratorAt method.
B. When a menu is focused it can be navigated using the keyboard (arrow keys, etc).
C. When a menu is focused character shortcuts can be displayed and enabled using the & character in the menu item label (e.g. "E&xit" will underline 'x' in the label, and pressing the letter X will trigger the command).
3. Add a callback for unhandled key events at the CefWindow level. This can be used, for example, to focus the MenuButton when the ALT key is pressed (and unhandled by any other control).