mirror of
https://github.com/textmate/textmate.git
synced 2026-04-28 03:00:34 -04:00
Handle ⌥⌘⇠ / ⌥⌘⇢ in main menu subclass
This means they work (as alternatives for ⌘[ / ⌘]) in all windows with tabs. We now also trigger menu-flashing for when pressing the keys.
This commit is contained in:
@@ -52,6 +52,21 @@ static CGPoint MenuPosition ()
|
||||
@end
|
||||
|
||||
@implementation OakMainMenu
|
||||
- (BOOL)performWindowMenuAction:(SEL)anAction
|
||||
{
|
||||
NSMenu* windowMenu = [[self itemWithTitle:@"Window"] submenu];
|
||||
NSInteger index = [windowMenu indexOfItemWithTarget:nil andAction:anAction];
|
||||
if(!windowMenu || index == -1)
|
||||
return [NSApp sendAction:anAction to:nil from:self];
|
||||
|
||||
[windowMenu update];
|
||||
if(![[windowMenu itemAtIndex:index] isEnabled])
|
||||
return NO;
|
||||
|
||||
[windowMenu performActionForItemAtIndex:index];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)performKeyEquivalent:(NSEvent*)anEvent
|
||||
{
|
||||
std::string const keyString = to_s(anEvent);
|
||||
@@ -75,6 +90,11 @@ static CGPoint MenuPosition ()
|
||||
}
|
||||
}
|
||||
|
||||
if(keyString == "~@\uF702") // ⌥⌘⇠
|
||||
return [self performWindowMenuAction:@selector(selectPreviousTab:)];
|
||||
else if(keyString == "~@\uF703") // ⌥⌘⇢
|
||||
return [self performWindowMenuAction:@selector(selectNextTab:)];
|
||||
|
||||
return [super performKeyEquivalent:anEvent];
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -509,17 +509,6 @@ static id SafeObjectAtIndex (NSArray* array, NSUInteger index)
|
||||
}
|
||||
@synthesize delegate, dataSource, slideAroundAnimationTimer, layoutNeedsUpdate;
|
||||
|
||||
- (BOOL)performKeyEquivalent:(NSEvent*)anEvent
|
||||
{
|
||||
// this should be in the window controller, but there we need subclassing mojo to get key events
|
||||
std::string const keyStr = to_s(anEvent);
|
||||
if(keyStr == "~@\uF702") // ⌥⌘⇠
|
||||
return [NSApp sendAction:@selector(selectPreviousTab:) to:nil from:self];
|
||||
else if(keyStr == "~@\uF703") // ⌥⌘⇢
|
||||
return [NSApp sendAction:@selector(selectNextTab:) to:nil from:self];
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(NSRect)aRect
|
||||
{
|
||||
if(self = [super initWithFrame:aRect])
|
||||
|
||||
Reference in New Issue
Block a user