HOBrowserView: Avoid calling super on key events

This workaround is to avoid a couple of undesired behaviors in the `HTMLOutputWindow` when the web page implements keyboard commands such as Git → Browse Annotated File (Blame). Namely, when using the keyboard commands, we would always receive an NSBeep. Also, fixed an issue when these key commands may conflict with menu keys. See comment in the commit for details.
This commit is contained in:
Ronald Wampler
2014-09-24 00:10:04 -04:00
committed by Allan Odgaard
parent 13a3ac49ba
commit a627991ac3

View File

@@ -108,6 +108,45 @@ static void ShowLoadErrorForURL (WebFrame* frame, NSURL* url, NSError* error)
}
}
// ==============
// = Key Events =
// ==============
/*
Since the webView is typically the first responder, the path for key events is as follows:
For keyDown:
webView
HOBrowserView
OakHTMLOutputView
NSWindow
For performKeyEquivalent:
NSWindow
OakHTMLOutputView
HOBrowserView
webView
A webView default implementation passes all key events, including potential key equivalents (except ESC),
to the webpage so that it may have a chance to respond. Unfortunately, we cannot know if these events are
handled so the events are still forwarded down their respective chains as shown above. So to avoid the
NSBeep when hitting the end of the responder chain, we let HOBrowserView swallow all key events. This is
safe since performKeyEquivalent: is called first, which leads to another problem: we can pass
the key event back to the webView (minus the modifier). Therefore, we also terminate the above chain for
performKeyEquivalent: by overriding the method here and returning just NO. Note: that if none of the views
in the hierachy returns YES, the key (equivalent) event is then passed to the menus.
*/
- (BOOL)performKeyEquivalent
{
return NO;
}
- (void)keyDown:(NSEvent*)anEvent
{
}
// =========
// = Swipe =
// =========