[vlc-devel] commit: macosx: fix key capture for hotkeys when setting new ones. ( Derk-Jan Hartman )

git version control git at videolan.org
Mon Aug 11 01:36:45 CEST 2008


vlc | branch: master | Derk-Jan Hartman <hartman at videolan.org> | Mon Aug 11 01:38:36 2008 +0200| [b80f556aa48897ca5bb6030691034dd7a81b084a] | committer: Derk-Jan Hartman 

macosx: fix key capture for hotkeys when setting new ones.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b80f556aa48897ca5bb6030691034dd7a81b084a
---

 modules/gui/macosx/simple_prefs.h |    4 +---
 modules/gui/macosx/simple_prefs.m |   19 ++++++++++++++++---
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/modules/gui/macosx/simple_prefs.h b/modules/gui/macosx/simple_prefs.h
index d02ebae..b37adcb 100644
--- a/modules/gui/macosx/simple_prefs.h
+++ b/modules/gui/macosx/simple_prefs.h
@@ -205,12 +205,10 @@
 - (void)showHotkeySettings;
 - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView;
 - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex;
-- (void)changeHotkeyTo: (int)i_theNewKey;
+- (BOOL)changeHotkeyTo: (int)i_theNewKey;
 
 @end
 
 @interface VLCHotkeyChangeWindow : NSWindow
 
-- (void)keyDown:(NSEvent *)theEvent;
-
 @end
diff --git a/modules/gui/macosx/simple_prefs.m b/modules/gui/macosx/simple_prefs.m
index edb5a20..4b2f2ab 100644
--- a/modules/gui/macosx/simple_prefs.m
+++ b/modules/gui/macosx/simple_prefs.m
@@ -1187,7 +1187,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
     }
 }
 
-- (void)changeHotkeyTo: (int)i_theNewKey
+- (BOOL)changeHotkeyTo: (int)i_theNewKey
 {
     int i_returnValue;
     i_returnValue = [o_hotkeysNonUseableKeys indexOfObject: [NSNumber numberWithInt: i_theNewKey]];
@@ -1196,6 +1196,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
         [o_hotkeys_change_keys_lbl setStringValue: _NS("Invalid combination")];
         [o_hotkeys_change_taken_lbl setStringValue: _NS("Regrettably, these keys cannot be assigned as hotkey shortcuts.")];
         [o_hotkeys_change_ok_btn setEnabled: NO];
+        return NO;
     }
     else
     {
@@ -1217,6 +1218,7 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
             [o_hotkeys_change_taken_lbl setStringValue: @""];
 
         [o_hotkeys_change_ok_btn setEnabled: YES];
+        return YES;
     }
 }
     
@@ -1228,13 +1230,23 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
 
 @implementation VLCHotkeyChangeWindow
 
+- (BOOL)acceptsFirstResponder
+{
+    return YES;
+}
+
+- (BOOL)becomeFirstResponder
+{
+    return YES;
+}
+
 - (BOOL)resignFirstResponder
 {
     /* We need to stay the first responder or we'll miss the user's input */
     return NO;
 }
 
-- (void)keyDown:(NSEvent *)o_theEvent
+- (BOOL)performKeyEquivalent:(NSEvent *)o_theEvent
 {
     unichar key;
     int i_key = 0;
@@ -1255,8 +1267,9 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
     if( key )
     {
         i_key |= CocoaKeyToVLC( key );
-        [[[VLCMain sharedInstance] getSimplePreferences] changeHotkeyTo: i_key];
+        return [[[VLCMain sharedInstance] getSimplePreferences] changeHotkeyTo: i_key];
     }
+    return FALSE;
 }
 
 @end




More information about the vlc-devel mailing list