Skip to content

Commit

Permalink
Multi line text view key handling: add check for first responder
Browse files Browse the repository at this point in the history
performKeyEquivalent is [documented](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html#//apple_ref/doc/uid/10000060i-CH3-SW10) to be called even if a view isn't first responder (this is for example how "Enter" binds to the default button on a dialog, for example -- the default button doesn't need to be focused to respond to Enter), but since we override performKeyEquivalent to properly support certain keyboard shortcuts (like noted in #1867), the previous assumption on the actual use of performKeyEquivalent no longer holds -- it's *only* for keystrokes sent in focused state, so add that check.
  • Loading branch information
nakambo committed Oct 8, 2024
1 parent a5b98ea commit 5e3e4aa
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ - (void)deleteBackward {
}
#else // [macOS
- (BOOL)performKeyEquivalent:(NSEvent *)event {
if (!self.hasMarkedText && ![self.textInputDelegate textInputShouldHandleKeyEvent:event]) {
if (self.window.firstResponder == self && !self.hasMarkedText && ![self.textInputDelegate textInputShouldHandleKeyEvent:event]) {
return YES;
}

Expand Down

0 comments on commit 5e3e4aa

Please sign in to comment.