Changeset 431
- Timestamp:
- 03/03/08 08:21:22 (17 years ago)
- Location:
- trunk/ICeCoffEE/ICeCoffEE
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEKeyEquivalents.m
r319 r431 140 140 return keyEquivalentAttributedString; 141 141 } 142 143 // converts NSUserKeyEquivalents prefixes into modifier flags 144 NSAttributedString *ICCF_KeyEquivalentAttributedString(NSString *self, unsigned count) { 145 unsigned modifierFlags = 0; 146 int i; 147 for (i = 0 ; i < [self length] - 1; i++) { 148 switch ([self characterAtIndex: i]) { 149 case '@': modifierFlags |= NSCommandKeyMask; break; 150 case '~': modifierFlags |= NSAlternateKeyMask; break; 151 case '^': modifierFlags |= NSControlKeyMask; break; 152 case '$': modifierFlags |= NSShiftKeyMask; break; 153 default: 154 return nil; 155 } 156 } 157 return ICCF_KeyEquivalentAttributedStringWithModifierFlags([self substringFromIndex: i], modifierFlags, count); 158 } 159 -
trunk/ICeCoffEE/ICeCoffEE/ICeCoffEEServicePrefController.m
r428 r431 29 29 30 30 static NSMutableDictionary *keyEquivalents; 31 static NSDictionary *userKeyEquivalents; 31 32 32 33 static void ICCF_RemoveSingleKeyEquivalents() { … … 75 76 76 77 static inline void ICCF_UpdateKeyEquivalentForItem(NSMenuItem *item, int state) { 78 return; // XXX disabled until we can affect menubar Services menu(s) 77 79 int oldState = ICCF_GetServiceState(item); 78 80 if ((oldState == ICCF_SERVICE_UNKNOWN || oldState == ICCF_SERVICE_SHOWN) && state == ICCF_SERVICE_HIDDEN) … … 204 206 } else { 205 207 NSString *keyEquivalent = (NSString *)[itemInfo objectForKey: (NSString *)kICServiceShortcut]; 208 if (keyEquivalent == nil) { 209 keyEquivalent = [userKeyEquivalents objectForKey: [menuItem title]]; 210 } else if ([keyEquivalent length] != 1) { 211 keyEquivalent = nil; 212 } else { 213 // XXX Inconsistency between Cocoa and Carbon: always command-shift in Carbon, not in Cocoa. Since we only patch Cocoa for the moment, keep as is. 214 unichar key = [keyEquivalent characterAtIndex: 0]; 215 if ([[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember: key]) 216 keyEquivalent = [NSString stringWithFormat: @"$@%c", key]; 217 else 218 keyEquivalent = [NSString stringWithFormat: @"@%c", key]; 219 } 206 220 if (keyEquivalent != nil) { 207 221 [menuItem setToolTip: keyEquivalent]; … … 274 288 - (void)dealloc; 275 289 { 276 [keyEquivalents release]; 277 [servicesMenu release]; 278 [closedTriangle release]; 279 [selectedClosedTriangle release]; 280 [openTriangle release]; 281 [selectedOpenTriangle release]; 290 [keyEquivalents release]; keyEquivalents = nil; 291 [userKeyEquivalents release]; userKeyEquivalents = nil; 292 [servicesMenu release]; servicesMenu = nil; 293 [closedTriangle release]; closedTriangle = nil; 294 [selectedClosedTriangle release]; selectedClosedTriangle = nil; 295 [openTriangle release]; openTriangle = nil; 296 [selectedOpenTriangle release]; selectedOpenTriangle = nil; 282 297 [super dealloc]; 283 298 } … … 336 351 if (servicesMenu == nil) { 337 352 keyEquivalents = [[NSMutableDictionary alloc] init]; 353 userKeyEquivalents = [[[NSUserDefaults standardUserDefaults] dictionaryForKey: @"NSUserKeyEquivalents"] retain]; 338 354 servicesMenu = [[NSMenu alloc] initWithTitle: @""]; 339 355 ICCF_SetServicesMenu(servicesMenu); … … 359 375 } 360 376 361 NSAttributedString *ICCF_KeyEquivalentAttributedString WithModifierFlags(NSString *self, unsigned int modifierFlags, unsigned count);377 NSAttributedString *ICCF_KeyEquivalentAttributedString(NSString *self, unsigned count); 362 378 363 379 - (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item; … … 380 396 } else if ([[tableColumn identifier] isEqualToString: @"key"]) { 381 397 NSString *equivalent = [item toolTip]; 382 if (equivalent == nil || [equivalent length] != 1) return nil;383 // XXX Inconsistency between Cocoa and Carbon: always command-shift in Carbon, not in Cocoa. Since we only patch Cocoa for the moment, keep as is. 384 return ICCF_KeyEquivalentAttributedString WithModifierFlags(equivalent, [item keyEquivalentModifierMask] | ([[NSCharacterSet uppercaseLetterCharacterSet] characterIsMember: [equivalent characterAtIndex: 0]] ? NSShiftKeyMask : 0), ICCF_CountForKeyEquivalent(equivalent));398 if (equivalent == nil) 399 return nil; 400 return ICCF_KeyEquivalentAttributedString(equivalent, ICCF_CountForKeyEquivalent(equivalent)); 385 401 } 386 402 return nil;
Note:
See TracChangeset
for help on using the changeset viewer.