summaryrefslogtreecommitdiffstats
path: root/macosx/NSWindow+HBAdditions.m
diff options
context:
space:
mode:
Diffstat (limited to 'macosx/NSWindow+HBAdditions.m')
-rw-r--r--macosx/NSWindow+HBAdditions.m41
1 files changed, 34 insertions, 7 deletions
diff --git a/macosx/NSWindow+HBAdditions.m b/macosx/NSWindow+HBAdditions.m
index 2951d7a1f..fbf65f116 100644
--- a/macosx/NSWindow+HBAdditions.m
+++ b/macosx/NSWindow+HBAdditions.m
@@ -1,10 +1,8 @@
-//
-// NSWindow+HBAdditions.m
-// HandBrake
-//
-// Created by Damiano Galassi on 25/04/16.
-//
-//
+/* NSWindow+HBAdditions.m
+
+ This file is part of the HandBrake source code.
+ Homepage: <http://handbrake.fr/>.
+ It may be used under the terms of the GNU General Public License. */
#import "NSWindow+HBAdditions.h"
@@ -75,5 +73,34 @@
return center;
}
+- (BOOL)HB_endEditing;
+{
+ BOOL success;
+ 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])
+ {
+ responder = ([[responder delegate] isKindOfClass:[NSResponder class]]) ? [responder delegate] : nil;
+ }
+
+ success = [self makeFirstResponder:nil];
+
+ // Return first responder status.
+ if (success && responder != nil)
+ {
+ [self makeFirstResponder:responder];
+ }
+
+ return success;
+}
+
+- (void)HB_forceEndEditing;
+{
+ [self endEditingFor:nil];
+}
+
+
@end