Make keyboard shortcuts work on Mac
When the renderer doesn't handle a key event, we pass it off to the main menu to see if it can handle it. Part of #2.
This commit is contained in:
parent
561fc9a342
commit
be6d990a97
4 changed files with 50 additions and 0 deletions
|
@ -23,6 +23,9 @@
|
|||
'browser/browser_main_parts.cc',
|
||||
'browser/browser_main_parts.h',
|
||||
'browser/browser_main_parts_mac.mm',
|
||||
'browser/default_web_contents_delegate.cc',
|
||||
'browser/default_web_contents_delegate.h',
|
||||
'browser/default_web_contents_delegate_mac.mm',
|
||||
'browser/devtools_delegate.cc',
|
||||
'browser/devtools_delegate.h',
|
||||
'browser/devtools_frontend.cc',
|
||||
|
|
11
brightray/browser/default_web_contents_delegate.cc
Normal file
11
brightray/browser/default_web_contents_delegate.cc
Normal file
|
@ -0,0 +1,11 @@
|
|||
#include "browser/default_web_contents_delegate.h"
|
||||
|
||||
namespace brightray {
|
||||
|
||||
DefaultWebContentsDelegate::DefaultWebContentsDelegate() {
|
||||
}
|
||||
|
||||
DefaultWebContentsDelegate::~DefaultWebContentsDelegate() {
|
||||
}
|
||||
|
||||
}
|
21
brightray/browser/default_web_contents_delegate.h
Normal file
21
brightray/browser/default_web_contents_delegate.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef BRIGHTRAY_BROWSER_DEFAULT_WEB_CONTENTS_DELEGATE_H_
|
||||
#define BRIGHTRAY_BROWSER_DEFAULT_WEB_CONTENTS_DELEGATE_H_
|
||||
|
||||
#include "content/public/browser/web_contents_delegate.h"
|
||||
|
||||
namespace brightray {
|
||||
|
||||
// This class provides some sane default behaviors to any content::WebContents instance (e.g.,
|
||||
// keyboard shortcut handling on Mac).
|
||||
class DefaultWebContentsDelegate : public content::WebContentsDelegate {
|
||||
public:
|
||||
DefaultWebContentsDelegate();
|
||||
~DefaultWebContentsDelegate();
|
||||
|
||||
protected:
|
||||
virtual void HandleKeyboardEvent(content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
15
brightray/browser/default_web_contents_delegate_mac.mm
Normal file
15
brightray/browser/default_web_contents_delegate_mac.mm
Normal file
|
@ -0,0 +1,15 @@
|
|||
#import "browser/default_web_contents_delegate.h"
|
||||
|
||||
#import "content/public/browser/native_web_keyboard_event.h"
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
namespace brightray {
|
||||
|
||||
void DefaultWebContentsDelegate::HandleKeyboardEvent(content::WebContents*, const content::NativeWebKeyboardEvent& event) {
|
||||
if (event.skip_in_browser)
|
||||
return;
|
||||
|
||||
[[NSApp mainMenu] performKeyEquivalent:event.os_event];
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue