views: Support per-accelerator priority config (fixes #3598)

This commit is contained in:
Marshall Greenblatt
2023-11-08 14:27:50 -05:00
parent 2b38e2f793
commit d3d465b32e
12 changed files with 77 additions and 40 deletions

View File

@@ -92,13 +92,18 @@ class CefBrowserView : public CefView {
virtual CefRefPtr<CefView> GetChromeToolbar() = 0;
///
/// Sets whether accelerators registered with CefWindow::SetAccelerator are
/// triggered before or after the event is sent to the CefBrowser. If
/// |prefer_accelerators| is true then the matching accelerator will be
/// triggered immediately and the event will not be sent to the CefBrowser. If
/// |prefer_accelerators| is false then the matching accelerator will only be
/// triggered if the event is not handled by web content or by
/// CefKeyboardHandler. The default value is false.
/// Sets whether normal priority accelerators are first forwarded to the web
/// content (`keydown` event handler) or CefKeyboardHandler. Normal priority
/// accelerators can be registered via CefWindow::SetAccelerator (with
/// |high_priority|=false) or internally for standard accelerators supported
/// by the Chrome runtime. If |prefer_accelerators| is true then the matching
/// accelerator will be triggered immediately (calling
/// CefWindowDelegate::OnAccelerator or CefCommandHandler::OnChromeCommand
/// respectively) and the event will not be forwarded to the web content or
/// CefKeyboardHandler first. If |prefer_accelerators| is false then the
/// matching accelerator will only be triggered if the event is not handled by
/// web content (`keydown` event handler that calls `event.preventDefault()`)
/// or by CefKeyboardHandler. The default value is false.
///
/*--cef()--*/
virtual void SetPreferAccelerators(bool prefer_accelerators) = 0;

View File

@@ -344,16 +344,25 @@ class CefWindow : public CefPanel {
///
/// Set the keyboard accelerator for the specified |command_id|. |key_code|
/// can be any virtual key or character value.
/// can be any virtual key or character value. Required modifier keys are
/// specified by |shift_pressed|, |ctrl_pressed| and/or |alt_pressed|.
/// CefWindowDelegate::OnAccelerator will be called if the keyboard
/// combination is triggered while this window has focus.
///
/// The |high_priority| value will be considered if a child CefBrowserView has
/// focus when the keyboard combination is triggered. If |high_priority| is
/// true then the key event will not be forwarded to the web content
/// (`keydown` event handler) or CefKeyboardHandler first. If |high_priority|
/// is false then the behavior will depend on the
/// CefBrowserView::SetPreferAccelerators configuration.
///
/*--cef()--*/
virtual void SetAccelerator(int command_id,
int key_code,
bool shift_pressed,
bool ctrl_pressed,
bool alt_pressed) = 0;
bool alt_pressed,
bool high_priority) = 0;
///
/// Remove the keyboard accelerator for the specified |command_id|.