mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-13 08:44:12 +03:00
Handle standard pasteboard keybindings in the dev tools
This commit adds a boolean constructor parameter to the AtomCefClient indicating whether it should handle the standard pasteboard commands for its associated browser. We pass `true` when constructing the client for the dev tools, so these commands work there.
This commit is contained in:
parent
86c4f7a805
commit
e649b2e6c6
@ -15,6 +15,10 @@
|
||||
AtomCefClient::AtomCefClient(){
|
||||
}
|
||||
|
||||
AtomCefClient::AtomCefClient(bool handlePasteboardCommands) {
|
||||
m_HandlePasteboardCommands = handlePasteboardCommands;
|
||||
}
|
||||
|
||||
AtomCefClient::~AtomCefClient() {
|
||||
}
|
||||
|
||||
@ -105,6 +109,15 @@ bool AtomCefClient::OnKeyEvent(CefRefPtr<CefBrowser> browser,
|
||||
if (event.modifiers == KEY_META && event.unmodified_character == 'r') {
|
||||
browser->SendProcessMessage(PID_RENDERER, CefProcessMessage::Create("reload"));
|
||||
}
|
||||
if (m_HandlePasteboardCommands && event.modifiers == KEY_META && event.unmodified_character == 'x') {
|
||||
browser->GetFocusedFrame()->Cut();
|
||||
}
|
||||
if (m_HandlePasteboardCommands && event.modifiers == KEY_META && event.unmodified_character == 'c') {
|
||||
browser->GetFocusedFrame()->Copy();
|
||||
}
|
||||
if (m_HandlePasteboardCommands && event.modifiers == KEY_META && event.unmodified_character == 'v') {
|
||||
browser->GetFocusedFrame()->Paste();
|
||||
}
|
||||
else if (event.modifiers == (KEY_META | KEY_ALT) && event.unmodified_character == 'i') {
|
||||
ToggleDevTools(browser);
|
||||
} else if (event.modifiers == KEY_META && event.unmodified_character == '`') {
|
||||
|
@ -16,9 +16,9 @@ class AtomCefClient : public CefClient,
|
||||
public CefRequestHandler {
|
||||
public:
|
||||
AtomCefClient();
|
||||
AtomCefClient(bool handlePasteboardCommands);
|
||||
virtual ~AtomCefClient();
|
||||
|
||||
|
||||
CefRefPtr<CefBrowser> GetBrowser() { return m_Browser; }
|
||||
|
||||
virtual CefRefPtr<CefContextMenuHandler> GetContextMenuHandler() OVERRIDE {
|
||||
@ -97,6 +97,7 @@ class AtomCefClient : public CefClient,
|
||||
|
||||
protected:
|
||||
CefRefPtr<CefBrowser> m_Browser;
|
||||
bool m_HandlePasteboardCommands = false;
|
||||
|
||||
void FocusNextWindow();
|
||||
void Open(std::string path);
|
||||
|
@ -131,7 +131,7 @@
|
||||
// devtools don't resize properly.
|
||||
// HACK: I hate this and want to place this code directly in showDevTools
|
||||
- (void)attachDevTools {
|
||||
_cefDevToolsClient = new AtomCefClient();
|
||||
_cefDevToolsClient = new AtomCefClient(true);
|
||||
std::string devtools_url = _cefClient->GetBrowser()->GetHost()->GetDevToolsURL(true);
|
||||
[self addBrowserToView:_devToolsView url:devtools_url.c_str() cefHandler:_cefDevToolsClient];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user