mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
views: Add support for accelerators (issue #2102)
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#define CEF_LIBCEF_BROWSER_VIEWS_WINDOW_IMPL_H_
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "include/views/cef_window.h"
|
||||
#include "include/views/cef_window_delegate.h"
|
||||
|
||||
@@ -13,6 +15,7 @@
|
||||
#include "libcef/browser/views/panel_impl.h"
|
||||
#include "libcef/browser/views/window_view.h"
|
||||
|
||||
#include "ui/base/accelerators/accelerator.h"
|
||||
#include "ui/views/controls/menu/menu_runner.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
|
||||
@@ -23,7 +26,8 @@ class MenuButton;
|
||||
class CefWindowImpl :
|
||||
public CefPanelImpl<CefWindowView, CefWindow, CefWindowDelegate>,
|
||||
public CefWindowView::Delegate,
|
||||
public CefMenuModelImpl::Observer {
|
||||
public CefMenuModelImpl::Observer,
|
||||
public ui::AcceleratorTarget {
|
||||
public:
|
||||
typedef CefPanelImpl<CefWindowView, CefWindow, CefWindowDelegate> ParentClass;
|
||||
|
||||
@@ -70,6 +74,13 @@ class CefWindowImpl :
|
||||
void SendMouseEvents(cef_mouse_button_type_t button,
|
||||
bool mouse_down,
|
||||
bool mouse_up) override;
|
||||
void SetAccelerator(int command_id,
|
||||
int key_code,
|
||||
bool shift_pressed,
|
||||
bool ctrl_pressed,
|
||||
bool alt_pressed) override;
|
||||
void RemoveAccelerator(int command_id) override;
|
||||
void RemoveAllAccelerators() override;
|
||||
|
||||
// CefViewAdapter methods:
|
||||
void Detach() override;
|
||||
@@ -91,6 +102,7 @@ class CefWindowImpl :
|
||||
|
||||
// CefWindowView::Delegate methods:
|
||||
bool CanWidgetClose() override;
|
||||
void OnWindowClosing() override;
|
||||
void OnWindowViewDeleted() override;
|
||||
|
||||
// CefMenuModelImpl::Observer methods:
|
||||
@@ -101,6 +113,14 @@ class CefWindowImpl :
|
||||
void GetDebugInfo(base::DictionaryValue* info,
|
||||
bool include_children) override;
|
||||
|
||||
// ui::AcceleratorTarget methods:
|
||||
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
|
||||
bool CanHandleAccelerators() const override;
|
||||
|
||||
// Called for key events that have not been handled by other controls in the
|
||||
// window. Returns true if the event was handled.
|
||||
bool OnKeyEvent(const CefKeyEvent& event);
|
||||
|
||||
void ShowMenu(views::MenuButton* menu_button,
|
||||
CefRefPtr<CefMenuModel> menu_model,
|
||||
const CefPoint& screen_point,
|
||||
@@ -128,6 +148,15 @@ class CefWindowImpl :
|
||||
CefRefPtr<CefMenuModelImpl> menu_model_;
|
||||
std::unique_ptr<views::MenuRunner> menu_runner_;
|
||||
|
||||
// Map of command_id to accelerator.
|
||||
typedef std::map<int, ui::Accelerator> AcceleratorMap;
|
||||
AcceleratorMap accelerator_map_;
|
||||
|
||||
#if defined(USE_AURA)
|
||||
// Native widget's handler to receive events after the event target.
|
||||
std::unique_ptr<ui::EventHandler> unhandled_key_event_handler_;
|
||||
#endif
|
||||
|
||||
IMPLEMENT_REFCOUNTING_DELETE_ON_UIT(CefWindowImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(CefWindowImpl);
|
||||
};
|
||||
|
Reference in New Issue
Block a user