[vlc-commits] macosx: fixed hotkey support for the arrow keys and improved their handling in the sprefs

Felix Paul Kühne git at videolan.org
Mon Sep 26 21:27:18 CEST 2011


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Sep 26 21:27:10 2011 +0200| [56aebbc71550d361a0f00794f8f05c81af0adada] | committer: Felix Paul Kühne

macosx: fixed hotkey support for the arrow keys and improved their handling in the sprefs

we'll need a similar fix for function keys and friends

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

 modules/gui/macosx/intf.m         |   12 ++++++++++++
 modules/gui/macosx/simple_prefs.m |   24 ++++++++++++++++++++----
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 75ea4a4..76ef502 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1137,6 +1137,18 @@ unsigned int CocoaKeyToVLC( unichar i_key )
         theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
         theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
     }
+    if ([theString length] > 1)
+    {
+        if([theString rangeOfString:@"Up"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSUpArrowFunctionKey];
+        else if([theString rangeOfString:@"Down"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSDownArrowFunctionKey];
+        else if([theString rangeOfString:@"Right"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSRightArrowFunctionKey];
+        else if([theString rangeOfString:@"Left"].location != NSNotFound)
+            return [NSString stringWithFormat:@"%C", NSLeftArrowFunctionKey];
+    }
+
     return theString;
 }
 
diff --git a/modules/gui/macosx/simple_prefs.m b/modules/gui/macosx/simple_prefs.m
index 19d9e82..ca1e117 100644
--- a/modules/gui/macosx/simple_prefs.m
+++ b/modules/gui/macosx/simple_prefs.m
@@ -85,6 +85,10 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
         theString = [theString stringByReplacingOccurrencesOfString:@"Ctrl" withString: [NSString stringWithUTF8String: "\xE2\x8C\x83"]];
         theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
         theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
+        theString = [theString stringByReplacingOccurrencesOfString:@"Right" withString:[NSString stringWithUTF8String:"\xE2\x86\x92"]];
+        theString = [theString stringByReplacingOccurrencesOfString:@"Left" withString:[NSString stringWithUTF8String:"\xE2\x86\x90"]];
+        theString = [theString stringByReplacingOccurrencesOfString:@"Up" withString:[NSString stringWithUTF8String:"\xE2\x86\x91"]];
+        theString = [theString stringByReplacingOccurrencesOfString:@"Down" withString:[NSString stringWithUTF8String:"\xE2\x86\x93"]];
         theString = [theString capitalizedString];
     }
     else
@@ -1256,6 +1260,9 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
 - (BOOL)performKeyEquivalent:(NSEvent *)o_theEvent
 {
     NSMutableString *tempString = [[[NSMutableString alloc] init] autorelease];
+    NSString *keyString = [o_theEvent characters];
+	unichar key = [keyString characterAtIndex:0];
+
     if( [o_theEvent modifierFlags] & NSControlKeyMask )
         [tempString appendString:@"Ctrl-"];
     
@@ -1268,11 +1275,20 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
     if( [o_theEvent modifierFlags] & NSCommandKeyMask )
         [tempString appendString:@"Command-"];
 
-    if (![[[o_theEvent charactersIgnoringModifiers] lowercaseString] isEqualToString:@""]) {
+    if( key == NSUpArrowFunctionKey )
+        [tempString appendString:@"Up"];
+    else if( key == NSDownArrowFunctionKey )
+        [tempString appendString:@"Down"];
+    else if( key == NSLeftArrowFunctionKey )
+        [tempString appendString:@"Left"];
+    else if( key == NSRightArrowFunctionKey )
+        [tempString appendString:@"Right"];
+    else if (![[[o_theEvent charactersIgnoringModifiers] lowercaseString] isEqualToString:@""])
         [tempString appendString:[[o_theEvent charactersIgnoringModifiers] lowercaseString]];
-            return [[[VLCMain sharedInstance] simplePreferences] changeHotkeyTo: tempString];
-    }
-    return NO;
+    else
+        return NO;
+
+    return [[[VLCMain sharedInstance] simplePreferences] changeHotkeyTo: tempString];
 }
 
 @end



More information about the vlc-commits mailing list