[vlc-commits] macosx: fixed handling of plus and minus keys

Felix Paul Kühne git at videolan.org
Mon Oct 3 20:44:07 CEST 2011


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Oct  3 20:43:03 2011 +0200| [3aed491e904ecb946a9328bbcc090ead32a8a24e] | committer: Felix Paul Kühne

macosx: fixed handling of plus and minus keys

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

 modules/gui/macosx/intf.m         |   16 ++++++++++++++--
 modules/gui/macosx/simple_prefs.m |   18 +++++++++++++++---
 2 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 7071ead..772e6cd 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1131,12 +1131,24 @@ unsigned int CocoaKeyToVLC( unichar i_key )
 - (NSString *)VLCKeyToString:(NSString *)theString
 {
     if (![theString isEqualToString:@""]) {
+        if ([theString characterAtIndex:([theString length] - 1)] != 0x2b)
+            theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
+        else
+        {
+            theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
+            theString = [NSString stringWithFormat:@"%@+", theString];
+        }
+        if ([theString characterAtIndex:([theString length] - 1)] != 0x2d)
+            theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
+        else
+        {
+            theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
+            theString = [NSString stringWithFormat:@"%@-", theString];
+        }
         theString = [theString stringByReplacingOccurrencesOfString:@"Command" withString:@""];
         theString = [theString stringByReplacingOccurrencesOfString:@"Alt" withString:@""];
         theString = [theString stringByReplacingOccurrencesOfString:@"Shift" withString:@""];
         theString = [theString stringByReplacingOccurrencesOfString:@"Ctrl" withString:@""];
-        theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
-        theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
     }
     if ([theString length] > 1)
     {
diff --git a/modules/gui/macosx/simple_prefs.m b/modules/gui/macosx/simple_prefs.m
index 7bf0b24..90be645 100644
--- a/modules/gui/macosx/simple_prefs.m
+++ b/modules/gui/macosx/simple_prefs.m
@@ -79,14 +79,26 @@ static VLCSimplePrefs *_o_sharedInstance = nil;
 - (NSString *)OSXStringKeyToString:(NSString *)theString
 {
     if (![theString isEqualToString:@""]) {
+        /* remove cruft */
+        if ([theString characterAtIndex:([theString length] - 1)] != 0x2b)
+            theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
+        else
+        {
+            theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
+            theString = [NSString stringWithFormat:@"%@+", theString];
+        }
+        if ([theString characterAtIndex:([theString length] - 1)] != 0x2d)
+            theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
+        else
+        {
+            theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
+            theString = [NSString stringWithFormat:@"%@-", theString];
+        }
         /* modifiers */
         theString = [theString stringByReplacingOccurrencesOfString:@"Command" withString: [NSString stringWithUTF8String: "\xE2\x8C\x98"]];
         theString = [theString stringByReplacingOccurrencesOfString:@"Alt" withString: [NSString stringWithUTF8String: "\xE2\x8C\xA5"]];
         theString = [theString stringByReplacingOccurrencesOfString:@"Shift" withString: [NSString stringWithUTF8String: "\xE2\x87\xA7"]];
         theString = [theString stringByReplacingOccurrencesOfString:@"Ctrl" withString: [NSString stringWithUTF8String: "\xE2\x8C\x83"]];
-        /* remove cruft */
-        theString = [theString stringByReplacingOccurrencesOfString:@"+" withString:@""];
-        theString = [theString stringByReplacingOccurrencesOfString:@"-" withString:@""];
         /* show non-character keys correctly */
         theString = [theString stringByReplacingOccurrencesOfString:@"Right" withString:[NSString stringWithUTF8String:"\xE2\x86\x92"]];
         theString = [theString stringByReplacingOccurrencesOfString:@"Left" withString:[NSString stringWithUTF8String:"\xE2\x86\x90"]];



More information about the vlc-commits mailing list