]> git.sesse.net Git - vlc/commitdiff
macosx: fixed handling of plus and minus keys
authorFelix Paul Kühne <fkuehne@videolan.org>
Mon, 3 Oct 2011 18:43:03 +0000 (20:43 +0200)
committerFelix Paul Kühne <fkuehne@videolan.org>
Mon, 3 Oct 2011 18:43:03 +0000 (20:43 +0200)
modules/gui/macosx/intf.m
modules/gui/macosx/simple_prefs.m

index 7071ead215842d5376a5a51211a9e8bc34785fb2..772e6cd12b648d0d200a03ad567c387ece6a2c59 100644 (file)
@@ -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)
     {
index 7bf0b2415ade9c3d2240e483f509f67a0826fa1e..90be645b54a76181a07fb39a8f968996b49cd470 100644 (file)
@@ -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"]];