chromiumembedded / cef

Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.
https://bitbucket.org/chromiumembedded/cef/
Other
3.36k stars 467 forks source link

views: Add support for accelerators (keyboard shortcuts) #2102

Closed magreenblatt closed 7 years ago

magreenblatt commented 7 years ago

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).

magreenblatt commented 7 years ago

Attached focused_menu.png is an example of what the focused CefMenuButton with accelerator and mnemonic (underlined) characters looks like.

magreenblatt commented 7 years ago

Some notes on relevant code paths in Chromium:

magreenblatt commented 7 years ago

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.

magreenblatt commented 7 years ago

Done in master revision bd1b801 (bb) and 2987 branch revision e31a44a (bb).

magreenblatt commented 7 years ago

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.

magreenblatt commented 7 years ago

Master revision 6eaf11f (bb) and 2987 branch revision 874e670 (bb) add support for top menu switching using mouse and arrow keys.

magreenblatt commented 7 years ago

Master revision 16125bd (bb) and 2987 branch revision b0c8a34 (bb) add support for mnemonic (underlined) characters in MenuButton labels.

magreenblatt commented 7 years ago

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).

magreenblatt commented 7 years ago
magreenblatt commented 7 years ago
magreenblatt commented 7 years ago