Use _cycleWindows selector to implement cmd-`
This commit is contained in:
parent
b4c48664f8
commit
be67dca686
1 changed files with 5 additions and 15 deletions
|
@ -896,21 +896,11 @@ void NativeWindowMac::HandleKeyboardEvent(
|
||||||
// Handle the cmd+~ shortcut.
|
// Handle the cmd+~ shortcut.
|
||||||
if ((event.os_event.modifierFlags & NSCommandKeyMask) /* cmd */ &&
|
if ((event.os_event.modifierFlags & NSCommandKeyMask) /* cmd */ &&
|
||||||
(event.os_event.keyCode == 50 /* ~ */)) {
|
(event.os_event.keyCode == 50 /* ~ */)) {
|
||||||
// Switch to next visible window.
|
if (event.os_event.modifierFlags & NSShiftKeyMask) {
|
||||||
NSArray* windows = [NSApp windows];
|
[NSApp sendAction:@selector(_cycleWindowsReversed:) to:nil from:nil];
|
||||||
NSIndexSet* indexes = [windows indexesOfObjectsPassingTest:
|
} else {
|
||||||
^BOOL(id window, NSUInteger idx, BOOL* stop) {
|
[NSApp sendAction:@selector(_cycleWindows:) to:nil from:nil];
|
||||||
return [window isVisible];
|
}
|
||||||
}];
|
|
||||||
if ([indexes count] == 0)
|
|
||||||
return;
|
|
||||||
NSUInteger current = [windows indexOfObject:event.os_event.window];
|
|
||||||
if (current == NSNotFound) // Some faked event.
|
|
||||||
return;
|
|
||||||
NSUInteger next = [indexes indexGreaterThanIndex:current];
|
|
||||||
if (next == NSNotFound)
|
|
||||||
next = [indexes firstIndex];
|
|
||||||
[[windows objectAtIndex:next] makeKeyAndOrderFront:nil];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue