views: Use UnhandledKeyboardEventHandler to handle accelerators.
This commit is contained in:
parent
3d36a6a793
commit
b99262af32
2 changed files with 7 additions and 9 deletions
|
@ -18,6 +18,7 @@
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
#include "ui/gfx/image/image_skia.h"
|
#include "ui/gfx/image/image_skia.h"
|
||||||
#include "ui/views/background.h"
|
#include "ui/views/background.h"
|
||||||
|
#include "ui/views/controls/webview/unhandled_keyboard_event_handler.h"
|
||||||
#include "ui/views/controls/webview/webview.h"
|
#include "ui/views/controls/webview/webview.h"
|
||||||
#include "ui/views/layout/fill_layout.h"
|
#include "ui/views/layout/fill_layout.h"
|
||||||
#include "ui/views/window/client_view.h"
|
#include "ui/views/window/client_view.h"
|
||||||
|
@ -56,6 +57,7 @@ NativeWindowViews::NativeWindowViews(content::WebContents* web_contents,
|
||||||
: NativeWindow(web_contents, options),
|
: NativeWindow(web_contents, options),
|
||||||
window_(new views::Widget),
|
window_(new views::Widget),
|
||||||
web_view_(inspectable_web_contents()->GetView()->GetView()),
|
web_view_(inspectable_web_contents()->GetView()->GetView()),
|
||||||
|
keyboard_event_handler_(new views::UnhandledKeyboardEventHandler),
|
||||||
resizable_(true) {
|
resizable_(true) {
|
||||||
options.Get(switches::kResizable, &resizable_);
|
options.Get(switches::kResizable, &resizable_);
|
||||||
options.Get(switches::kTitle, &title_);
|
options.Get(switches::kTitle, &title_);
|
||||||
|
@ -369,15 +371,7 @@ views::NonClientFrameView* NativeWindowViews::CreateNonClientFrameView(
|
||||||
void NativeWindowViews::HandleKeyboardEvent(
|
void NativeWindowViews::HandleKeyboardEvent(
|
||||||
content::WebContents*,
|
content::WebContents*,
|
||||||
const content::NativeWebKeyboardEvent& event) {
|
const content::NativeWebKeyboardEvent& event) {
|
||||||
if (event.type == blink::WebInputEvent::RawKeyDown) {
|
keyboard_event_handler_->HandleKeyboardEvent(event, GetFocusManager());
|
||||||
ui::Accelerator accelerator(
|
|
||||||
static_cast<ui::KeyboardCode>(event.windowsKeyCode),
|
|
||||||
content::GetModifiersFromNativeWebKeyboardEvent(event));
|
|
||||||
|
|
||||||
if (GetFocusManager()->ProcessAccelerator(accelerator)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindowViews::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
bool NativeWindowViews::AcceleratorPressed(const ui::Accelerator& accelerator) {
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "ui/views/widget/widget_delegate.h"
|
#include "ui/views/widget/widget_delegate.h"
|
||||||
|
|
||||||
namespace views {
|
namespace views {
|
||||||
|
class UnhandledKeyboardEventHandler;
|
||||||
class Widget;
|
class Widget;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,6 +106,9 @@ class NativeWindowViews : public NativeWindow,
|
||||||
scoped_ptr<views::Widget> window_;
|
scoped_ptr<views::Widget> window_;
|
||||||
views::View* web_view_; // Managed by inspectable_web_contents_.
|
views::View* web_view_; // Managed by inspectable_web_contents_.
|
||||||
|
|
||||||
|
// Handles unhandled keyboard messages coming back from the renderer process.
|
||||||
|
scoped_ptr<views::UnhandledKeyboardEventHandler> keyboard_event_handler_;
|
||||||
|
|
||||||
// Map from accelerator to menu item's command id.
|
// Map from accelerator to menu item's command id.
|
||||||
accelerator_util::AcceleratorTable accelerator_table_;
|
accelerator_util::AcceleratorTable accelerator_table_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue