зеркало из https://github.com/mozilla/gecko-dev.git
Bug 429824: Let OSX's native menu system handle keyboard shortcuts that we did not handle ourselves via XBL prototype handlers. This allows for handling of custom shortcuts, but does not allow for reassignment of existing shortcuts. r=mstange
This commit is contained in:
Родитель
0c7107f70c
Коммит
340eaff79d
|
@ -5554,10 +5554,23 @@ GetIntegerDeltaForEvent(NSEvent* aEvent)
|
|||
handled = mTextInputHandler->HandleKeyDownEvent(theEvent);
|
||||
}
|
||||
|
||||
// We always allow keyboard events to propagate to keyDown: but if they are not
|
||||
// handled we give special Application menu items a chance to act.
|
||||
// We always allow keyboard events to propagate to keyDown: but if they are
|
||||
// not handled we give menu items a chance to act. This allows for handling of
|
||||
// custom shortcuts. Note that existing shortcuts cannot be reassigned yet and
|
||||
// will have been handled by keyDown: before we get here.
|
||||
if (!handled && mGeckoChild) {
|
||||
nsCocoaWindow* widget = mGeckoChild->GetXULWindowWidget();
|
||||
if (widget) {
|
||||
nsMenuBarX* mb = widget->GetMenuBar();
|
||||
if (mb) {
|
||||
// Check if main menu wants to handle the event.
|
||||
handled = mb->PerformKeyEquivalent(theEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!handled && sApplicationMenu) {
|
||||
[sApplicationMenu performKeyEquivalent:theEvent];
|
||||
// Check if application menu wants to handle the event.
|
||||
handled = [sApplicationMenu performKeyEquivalent:theEvent];
|
||||
}
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
|
|
|
@ -47,6 +47,7 @@ protected:
|
|||
@interface GeckoNSMenu : NSMenu
|
||||
{
|
||||
}
|
||||
- (BOOL)performSuperKeyEquivalent:(NSEvent*)theEvent;
|
||||
@end
|
||||
|
||||
// Objective-C class used as action target for menu items
|
||||
|
@ -119,6 +120,7 @@ public:
|
|||
static void ResetNativeApplicationMenu();
|
||||
void SetNeedsRebuild();
|
||||
void ApplicationMenuOpened();
|
||||
bool PerformKeyEquivalent(NSEvent* theEvent);
|
||||
|
||||
protected:
|
||||
void ConstructNativeMenus();
|
||||
|
|
|
@ -527,6 +527,11 @@ void nsMenuBarX::ApplicationMenuOpened()
|
|||
}
|
||||
}
|
||||
|
||||
bool nsMenuBarX::PerformKeyEquivalent(NSEvent* theEvent)
|
||||
{
|
||||
return [mNativeMenu performSuperKeyEquivalent:theEvent];
|
||||
}
|
||||
|
||||
// Hide the item in the menu by setting the 'hidden' attribute. Returns it in |outHiddenNode| so
|
||||
// the caller can hang onto it if they so choose. It is acceptable to pass nsull
|
||||
// for |outHiddenNode| if the caller doesn't care about the hidden node.
|
||||
|
@ -876,6 +881,11 @@ static BOOL gMenuItemsExecuteCommands = YES;
|
|||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)performSuperKeyEquivalent:(NSEvent*)theEvent
|
||||
{
|
||||
return [super performKeyEquivalent:theEvent];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче