diff options
Diffstat (limited to 'macosx/NSWindow+HBAdditions.m')
-rw-r--r-- | macosx/NSWindow+HBAdditions.m | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/macosx/NSWindow+HBAdditions.m b/macosx/NSWindow+HBAdditions.m index fbf65f116..ddb9a7899 100644 --- a/macosx/NSWindow+HBAdditions.m +++ b/macosx/NSWindow+HBAdditions.m @@ -76,13 +76,19 @@ - (BOOL)HB_endEditing; { BOOL success; + NSRange selectedRange = NSMakeRange(0, 0); id responder = self.firstResponder; // If we're dealing with the field editor, the real first responder is // its delegate. - if ((responder != nil) && [responder isKindOfClass:[NSTextView class]] && [(NSTextView*)responder isFieldEditor]) + if ((responder != nil) && [responder isKindOfClass:[NSTextView class]] && [(NSTextView *)responder isFieldEditor]) { responder = ([[responder delegate] isKindOfClass:[NSResponder class]]) ? [responder delegate] : nil; + if ([responder isKindOfClass:[NSTextField class]]) + { + NSTextField *textField = (NSTextField *)responder; + selectedRange = textField.currentEditor.selectedRange; + } } success = [self makeFirstResponder:nil]; @@ -91,6 +97,11 @@ if (success && responder != nil) { [self makeFirstResponder:responder]; + if ([responder isKindOfClass:[NSTextField class]]) + { + NSTextField *textField = (NSTextField *)responder; + textField.currentEditor.selectedRange = selectedRange; + } } return success; |