1 #import "MainController.h"
2 #import "PreferencesController.h"
3 #import "HotKeyCenter.h"
4 #import "StatusWindow.h"
6 @interface MainController(Private)
7 - (ITMTRemote *)loadRemote;
9 - (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers
10 onItem:(NSMenuItem *)item;
12 - (NSMenu *)songRatingMenu;
13 - (NSMenu *)playlistsMenu;
14 - (NSMenu *)upcomingSongsMenu;
15 - (NSMenu *)eqPresetsMenu;
18 @implementation MainController
22 if ( ( self = [super init] ) ) {
23 remoteArray = [[NSMutableArray alloc] initWithCapacity:1];
24 statusWindow = [StatusWindow sharedWindow];
32 [refreshTimer invalidate];
33 [refreshTimer release];
41 - (void)applicationDidFinishLaunching:(NSNotification *)note
43 currentRemote = [self loadRemote];
44 [currentRemote begin];
46 //Setup for notification of the remote player launching or quitting
47 [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(applicationTerminated:) name:NSWorkspaceDidTerminateApplicationNotification object:nil];
48 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationLaunched:) name:NSWorkspaceDidLaunchApplicationNotification object:nil];
50 [self registerDefaults];
52 statusItem = [[ITStatusItem alloc] initWithStatusBar:[NSStatusBar systemStatusBar] withLength:NSSquareStatusItemLength];
53 [statusItem setImage:[NSImage imageNamed:@"menu"]];
54 [statusItem setAlternateImage:[NSImage imageNamed:@"selected_image"]];
55 // Below line of code is for creating builds for Beta Testers
56 // [statusItem setToolTip:@[NSString stringWithFormat:@"This Nontransferable Beta (Built on %s) of iThink Software's MenuTunes is Registered to: Beta Tester (betatester@somedomain.com).",__DATE__]];
58 if ( ( [currentRemote playerRunningState] == ITMTRemotePlayerRunning ) ) {
59 [self applicationLaunched:nil];
61 [self applicationTerminated:nil];
65 - (void)applicationWillTerminate:(NSNotification *)note
68 [[NSStatusBar systemStatusBar] removeStatusItem:statusItem];
69 [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self];
75 - (ITMTRemote *)loadRemote
77 NSString *folderPath = [[NSBundle mainBundle] builtInPlugInsPath];
80 NSArray *bundlePathList = [NSBundle pathsForResourcesOfType:@"remote" inDirectory:folderPath];
81 NSEnumerator *enumerator = [bundlePathList objectEnumerator];
84 while ( (bundlePath = [enumerator nextObject]) ) {
85 NSBundle* remoteBundle = [NSBundle bundleWithPath:bundlePath];
88 Class remoteClass = [remoteBundle principalClass];
90 if ([remoteClass conformsToProtocol:@protocol(ITMTRemote)] &&
91 [remoteClass isKindOfClass:[NSObject class]]) {
93 id remote = [remoteClass remote];
94 [remoteArray addObject:remote];
99 // if ( [remoteArray count] > 0 ) { // UNCOMMENT WHEN WE HAVE > 1 PLUGIN
100 // if ( [remoteArray count] > 1 ) {
101 // [remoteArray sortUsingSelector:@selector(sortAlpha:)];
103 // [self loadModuleAccessUI]; //Comment out this line to disable remote visibility
106 // NSLog(@"%@", [remoteArray objectAtIndex:0]); //DEBUG
107 return [remoteArray objectAtIndex:0];
110 - (void)registerDefaults
112 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
113 if (![defaults objectForKey:@"menu"]) {
115 NSMutableDictionary *loginwindow;
116 NSMutableArray *loginarray;
120 [NSArray arrayWithObjects:
134 @"Current Track Info",
135 nil] forKey:@"menu"];
137 [defaults synchronize];
138 loginwindow = [[defaults persistentDomainForName:@"loginwindow"] mutableCopy];
139 loginarray = [loginwindow objectForKey:@"AutoLaunchedApplicationDictionary"];
141 for (i = 0; i < [loginarray count]; i++) {
142 NSDictionary *tempDict = [loginarray objectAtIndex:i];
143 if ([[[tempDict objectForKey:@"Path"] lastPathComponent] isEqualToString:[[[NSBundle mainBundle] bundlePath] lastPathComponent]]) {
150 //We must fix it so it is no longer suxy
152 if (NSRunInformationalAlertPanel(@"Auto-launch MenuTunes", @"Would you like MenuTunes to automatically launch at login?", @"Yes", @"No", nil) == NSOKButton) {
153 AEDesc scriptDesc, resultDesc;
154 NSString *script = [NSString stringWithFormat:@"tell application \"System Events\"\nmake new login item at end of login items with properties {path:\"%@\", kind:\"APPLICATION\"}\nend tell", [[NSBundle mainBundle] bundlePath]];
155 ComponentInstance asComponent = OpenDefaultComponent(kOSAComponentType, kAppleScriptSubtype);
157 AECreateDesc(typeChar, [script cString], [script cStringLength],
160 OSADoScript(asComponent, &scriptDesc, kOSANullScript, typeChar, kOSAModeCanInteract, &resultDesc);
162 AEDisposeDesc(&scriptDesc);
163 AEDisposeDesc(&resultDesc);
165 CloseComponent(asComponent);
170 if (![defaults integerForKey:@"SongsInAdvance"])
172 [defaults setInteger:5 forKey:@"SongsInAdvance"];
175 if (![defaults objectForKey:@"showName"]) {
176 [defaults setBool:YES forKey:@"showName"];
179 if (![defaults objectForKey:@"showArtist"]) {
180 [defaults setBool:YES forKey:@"showArtist"];
183 if (![defaults objectForKey:@"showAlbum"]) {
184 [defaults setBool:NO forKey:@"showAlbum"];
187 if (![defaults objectForKey:@"showTime"]) {
188 [defaults setBool:NO forKey:@"showTime"];
195 - (void)applicationLaunched:(NSNotification *)note
197 if (!note || [[[note userInfo] objectForKey:@"NSApplicationName"] isEqualToString:[currentRemote playerFullName]]) {
198 [NSThread detachNewThreadSelector:@selector(startTimerInNewThread) toTarget:self withObject:nil];
199 [statusItem setMenu:[self mainMenu]];
201 isAppRunning = ITMTRemotePlayerRunning;
205 isAppRunning = ITMTRemotePlayerRunning;
208 - (void)applicationTerminated:(NSNotification *)note
210 if (!note || [[[note userInfo] objectForKey:@"NSApplicationName"] isEqualToString:[currentRemote playerFullName]]) {
211 NSMenu *menu = [[NSMenu alloc] initWithTitle:@""];
212 [[menu addItemWithTitle:[NSString stringWithFormat:@"Open %@", [currentRemote playerSimpleName]] action:@selector(showPlayer:) keyEquivalent:@""] setTarget:self];
213 [menu addItem:[NSMenuItem separatorItem]];
214 [[menu addItemWithTitle:@"Preferences" action:@selector(showPreferences:) keyEquivalent:@""] setTarget:self];
215 [[menu addItemWithTitle:@"Quit" action:@selector(quitMenuTunes:) keyEquivalent:@""] setTarget:self];
216 [statusItem setMenu:[menu autorelease]];
218 [refreshTimer invalidate];
219 [refreshTimer release];
227 - (void)startTimerInNewThread
229 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
230 NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
231 refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES] retain];
238 ITMTRemotePlayerPlayingState playerPlayingState = [currentRemote playerPlayingState];
239 NSMenu *statusMenu = [statusItem menu];
242 //Update play/pause menu item
243 if (playerPlayingState == ITMTRemotePlayerPlaying) {
244 index = [statusMenu indexOfItemWithTitle:@"Play"];
246 [[statusMenu itemAtIndex:index] setTitle:@"Pause"];
249 index = [statusMenu indexOfItemWithTitle:@"Pause"];
251 [[statusMenu itemAtIndex:index] setTitle:@"Play"];
255 if (0 == 1/*Maybe set this to something better sometime*/) {
256 [statusItem setMenu:[self mainMenu]];
265 NSMenu *mainMenu = [[NSMenu alloc] initWithTitle:@""];
266 NSArray *myMenu = [[NSUserDefaults standardUserDefaults] arrayForKey:@"menu"];
269 for (i = 0; i < [myMenu count]; i++) {
270 NSString *currentItem = [myMenu objectAtIndex:i];
272 if ([currentItem isEqualToString:@"Play/Pause"]) {
273 KeyCombo *tempCombo = [[NSUserDefaults standardUserDefaults] keyComboForKey:@"PlayPause"];
274 NSMenuItem *playPauseMenuItem = [mainMenu addItemWithTitle:@"Play" action:@selector(playPause:) keyEquivalent:@""];
275 [playPauseMenuItem setTarget:self];
278 [self setKeyEquivalentForCode:[tempCombo keyCode]
279 andModifiers:[tempCombo modifiers] onItem:playPauseMenuItem];
282 } else if ([currentItem isEqualToString:@"Next Track"]) {
283 KeyCombo *tempCombo = [[NSUserDefaults standardUserDefaults] keyComboForKey:@"NextTrack"];
284 NSMenuItem *nextTrack = [mainMenu addItemWithTitle:@"Next Track" action:@selector(nextSong:) keyEquivalent:@""];
285 [nextTrack setTarget:self];
287 [self setKeyEquivalentForCode:[tempCombo keyCode]
288 andModifiers:[tempCombo modifiers] onItem:nextTrack];
291 } else if ([currentItem isEqualToString:@"Previous Track"]) {
292 KeyCombo *tempCombo = [[NSUserDefaults standardUserDefaults] keyComboForKey:@"PrevTrack"];
293 NSMenuItem *prevTrack = [mainMenu addItemWithTitle:@"Previous Track" action:@selector(prevSong:) keyEquivalent:@""];
294 [prevTrack setTarget:self];
296 [self setKeyEquivalentForCode:[tempCombo keyCode]
297 andModifiers:[tempCombo modifiers] onItem:prevTrack];
300 } else if ([currentItem isEqualToString:@"Fast Forward"]) {
301 [[mainMenu addItemWithTitle:@"Fast Forward"action:@selector(fastForward:) keyEquivalent:@""] setTarget:self];
302 } else if ([currentItem isEqualToString:@"Rewind"]) {
303 [[mainMenu addItemWithTitle:@"Rewind" action:@selector(rewind:) keyEquivalent:@""] setTarget:self];
304 } else if ([currentItem isEqualToString:@"EQ Presets"]) {
305 [[mainMenu addItemWithTitle:@"EQ Presets" action:NULL keyEquivalent:@""] setSubmenu:[self eqPresetsMenu]];
306 } else if ([currentItem isEqualToString:@"Playlists"]) {
307 [[mainMenu addItemWithTitle:@"Playlists" action:NULL keyEquivalent:@""] setSubmenu:[self playlistsMenu]];
308 } else if ([currentItem isEqualToString:@"Song Rating"]) {
309 [[mainMenu addItemWithTitle:@"Song Rating"action:NULL keyEquivalent:@""] setSubmenu:[self songRatingMenu]];
310 } else if ([currentItem isEqualToString:@"Upcoming Songs"]) {
311 [[mainMenu addItemWithTitle:@"Upcoming Songs"action:NULL keyEquivalent:@""] setSubmenu:[self upcomingSongsMenu]];
312 } else if ([currentItem isEqualToString:@"PreferencesÉ"]) {
313 [[mainMenu addItemWithTitle:@"Preferences..." action:@selector(showPreferences:) keyEquivalent:@""] setTarget:self];
314 } else if ([currentItem isEqualToString:@"Quit"]) {
315 [[mainMenu addItemWithTitle:@"Quit" action:@selector(quitMenuTunes:) keyEquivalent:@""] setTarget:self];
316 } else if ([currentItem isEqualToString:@"Current Song Info"]) {
319 int currentSongIndex = [currentRemote currentSongIndex];
321 if (currentSongIndex == 0) {
322 [mainMenu addItemWithTitle:@"No Song" action:NULL keyEquivalent:@""];
324 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
325 [mainMenu addItemWithTitle:@"Now Playing" action:NULL keyEquivalent:@""];
327 if ([defaults objectForKey:@"showName"]) {
328 [mainMenu addItemWithTitle:[NSString stringWithFormat:@" %@", [currentRemote currentSongTitle]] action:NULL keyEquivalent:@""];
331 if ([defaults objectForKey:@"showAlbum"]) {
332 [mainMenu addItemWithTitle:[NSString stringWithFormat:@" %@", [currentRemote currentSongAlbum]] action:NULL keyEquivalent:@""];
335 if ([defaults objectForKey:@"showArtist"]) {
336 [mainMenu addItemWithTitle:[NSString stringWithFormat:@" %@", [currentRemote currentSongArtist]] action:NULL keyEquivalent:@""];
339 if ([defaults objectForKey:@"showTime"]) {
340 [mainMenu addItemWithTitle:[NSString stringWithFormat:@" %@", [currentRemote currentSongLength]] action:NULL keyEquivalent:@""];
344 } else if ([currentItem isEqualToString:@"<separator>"]) {
345 [mainMenu addItem:[NSMenuItem separatorItem]];
349 NSLog(@"%@", mainMenu);
350 return [mainMenu autorelease];
353 - (NSMenu *)songRatingMenu
355 NSMenu *songRatingMenu = [[NSMenu alloc] initWithTitle:@""];
356 unichar fullstar = 0x2605;
357 unichar emptystar = 0x2606;
358 NSString *fullStarChar = [NSString stringWithCharacters:&fullstar length:1];
359 NSString *emptyStarChar = [NSString stringWithCharacters:&emptystar length:1];
361 int currentSongRating = ([currentRemote currentSongRating] * 5);
363 item = [songRatingMenu addItemWithTitle:[NSString stringWithFormat:@"%@%@%@%@%@", emptyStarChar, emptyStarChar, emptyStarChar, emptyStarChar, emptyStarChar] action:@selector(selectSongRating:) keyEquivalent:@""];
364 [item setTarget:self];
367 item = [songRatingMenu addItemWithTitle:[NSString stringWithFormat:@"%@%@%@%@%@", fullStarChar, emptyStarChar, emptyStarChar, emptyStarChar, emptyStarChar] action:@selector(selectSongRating:) keyEquivalent:@""];
368 [item setTarget:self];
371 item = [songRatingMenu addItemWithTitle:[NSString stringWithFormat:@"%@%@%@%@%@", fullStarChar, fullStarChar, emptyStarChar, emptyStarChar, emptyStarChar] action:@selector(selectSongRating:) keyEquivalent:@""];
372 [item setTarget:self];
375 item = [songRatingMenu addItemWithTitle:[NSString stringWithFormat:@"%@%@%@%@%@", fullStarChar, fullStarChar, fullStarChar, emptyStarChar, emptyStarChar] action:@selector(selectSongRating:) keyEquivalent:@""];
376 [item setTarget:self];
379 item = [songRatingMenu addItemWithTitle:[NSString stringWithFormat:@"%@%@%@%@%@", fullStarChar, fullStarChar, fullStarChar, fullStarChar, emptyStarChar] action:@selector(selectSongRating:) keyEquivalent:@""];
380 [item setTarget:self];
383 item = [songRatingMenu addItemWithTitle:[NSString stringWithFormat:@"%@%@%@%@%@", fullStarChar, fullStarChar, fullStarChar, fullStarChar, fullStarChar] action:@selector(selectSongRating:) keyEquivalent:@""];
384 [item setTarget:self];
387 [[songRatingMenu itemAtIndex:(currentSongRating / 20)] setState:NSOnState];
389 return [songRatingMenu autorelease];
392 - (void)selectSongRating:(id)sender
394 [currentRemote setCurrentSongRating:(float)[sender tag] / 100.0];
397 - (NSMenu *)playlistsMenu
399 NSMenu *playlistsMenu = [[NSMenu alloc] initWithTitle:@""];
400 NSArray *playlists = [currentRemote playlists];
401 int i, currentPlaylistIndex = [currentRemote currentPlaylistIndex];
403 if ([currentRemote classOfPlaylistAtIndex:currentPlaylistIndex] == ITMTRemotePlayerRadioPlaylist) {
404 currentPlaylistIndex = 0;
407 for (i = 0; i < [playlists count]; i++) {
408 NSString *name = [playlists objectAtIndex:i];
410 item = [playlistsMenu addItemWithTitle:name action:@selector(selectPlaylist:) keyEquivalent:@""];
411 [item setTarget:self];
414 if (i + 1 == currentPlaylistIndex) {
415 [item setState:NSOnState];
418 return [playlistsMenu autorelease];
421 - (void)selectPlaylist:(id)sender
423 int newPlaylistIndex = [sender tag];
424 if ([currentRemote currentPlaylistIndex] + 1 != newPlaylistIndex) {
425 [currentRemote switchToPlaylistAtIndex:newPlaylistIndex];
429 - (NSMenu *)upcomingSongsMenu
431 NSMenu *upcomingSongsMenu;
432 int i, currentPlaylistIndex, currentPlaylistLength, currentSongIndex, songsInAdvance;
434 if ([currentRemote classOfPlaylistAtIndex:currentPlaylistIndex] == ITMTRemotePlayerRadioPlaylist)
439 upcomingSongsMenu = [[NSMenu alloc] initWithTitle:@""];
440 currentPlaylistIndex = [currentRemote currentPlaylistIndex];
441 currentPlaylistLength = [currentRemote numberOfSongsInPlaylistAtIndex:currentPlaylistIndex];
442 currentSongIndex = [currentRemote currentSongIndex];
443 songsInAdvance = 8; //Change according to the preferences
445 for (i = currentSongIndex + 1; i <= currentSongIndex + songsInAdvance; i++) {
446 if (i <= currentPlaylistLength) {
447 NSString *name = [currentRemote songTitleAtIndex:i];
450 item = [upcomingSongsMenu addItemWithTitle:name action:@selector(selectUpcomingSong:) keyEquivalent:@""];
451 [item setTarget:self];
455 return [upcomingSongsMenu autorelease];
458 - (void)selectUpcomingSong:(id)sender
460 [currentRemote switchToSongAtIndex:[sender tag]];
463 - (NSMenu *)eqPresetsMenu
465 NSMenu *eqPresetsMenu = [[NSMenu alloc] initWithTitle:@""];
466 NSArray *eqPresets = [currentRemote eqPresets];
467 int i, currentPresetIndex = [currentRemote currentEQPresetIndex];
469 NSMenuItem *eqEnabledMenuItem;
471 eqEnabledMenuItem = [eqPresetsMenu addItemWithTitle:@"Enabled" action:@selector(selectEQPreset:) keyEquivalent:@""];
472 [eqEnabledMenuItem setTarget:self];
473 [eqEnabledMenuItem setTag:-1];
474 if ([currentRemote equalizerEnabled] == YES) {
475 [eqEnabledMenuItem setState:NSOnState];
478 [eqPresetsMenu addItem:[NSMenuItem separatorItem]];
480 for (i = 0; i < [eqPresets count]; i++) {
481 NSString *name = [eqPresets objectAtIndex:i];
484 item = [eqPresetsMenu addItemWithTitle:name action:@selector(selectEQPreset:) keyEquivalent:@""];
485 [item setTarget:self];
488 if (currentPresetIndex == i) {
489 [item setState:NSOnState];
492 return [eqPresetsMenu autorelease];
495 - (void)selectEQPreset:(id)sender
497 int newEQPresetIndex = [sender tag];
499 if (newEQPresetIndex == -1) {
500 [currentRemote setEqualizerEnabled:![currentRemote equalizerEnabled]];
503 if ([currentRemote currentEQPresetIndex] + 1 != newEQPresetIndex) {
504 [currentRemote switchToEQAtIndex:newEQPresetIndex];
513 [[HotKeyCenter sharedCenter] removeHotKey:@"PlayPause"];
514 [[HotKeyCenter sharedCenter] removeHotKey:@"NextTrack"];
515 [[HotKeyCenter sharedCenter] removeHotKey:@"PrevTrack"];
516 [[HotKeyCenter sharedCenter] removeHotKey:@"TrackInfo"];
517 [[HotKeyCenter sharedCenter] removeHotKey:@"UpcomingSongs"];
522 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
524 if ([defaults objectForKey:@"PlayPause"] != nil) {
525 [[HotKeyCenter sharedCenter] addHotKey:@"PlayPause"
526 combo:[defaults keyComboForKey:@"PlayPause"]
527 target:self action:@selector(playPause:)];
530 if ([defaults objectForKey:@"NextTrack"] != nil) {
531 [[HotKeyCenter sharedCenter] addHotKey:@"NextTrack"
532 combo:[defaults keyComboForKey:@"NextTrack"]
533 target:self action:@selector(nextSong:)];
536 if ([defaults objectForKey:@"PrevTrack"] != nil) {
537 [[HotKeyCenter sharedCenter] addHotKey:@"PrevTrack"
538 combo:[defaults keyComboForKey:@"PrevTrack"]
539 target:self action:@selector(prevSong:)];
542 if ([defaults objectForKey:@"TrackInfo"] != nil) {
543 [[HotKeyCenter sharedCenter] addHotKey:@"TrackInfo"
544 combo:[defaults keyComboForKey:@"TrackInfo"]
545 target:self action:@selector(showCurrentTrackInfo)];
548 if ([defaults objectForKey:@"UpcomingSongs"] != nil) {
549 [[HotKeyCenter sharedCenter] addHotKey:@"UpcomingSongs"
550 combo:[defaults keyComboForKey:@"UpcomingSongs"]
551 target:self action:@selector(showUpcomingSongs)];
558 - (void)playPause:(id)sender
560 ITMTRemotePlayerPlayingState state = [currentRemote playerPlayingState];
561 NSMenu *statusMenu = [statusItem menu];
563 if (state == ITMTRemotePlayerPlaying) {
564 [currentRemote pause];
565 [[statusMenu itemAtIndex:[statusMenu indexOfItemWithTitle:@"Pause"]] setTitle:@"Play"];
566 } else if ((state == ITMTRemotePlayerForwarding) || (state == ITMTRemotePlayerRewinding)) {
567 [currentRemote pause];
568 [currentRemote play];
570 [currentRemote play];
571 [[statusMenu itemAtIndex:[statusMenu indexOfItemWithTitle:@"Play"]] setTitle:@"Pause"];
575 - (void)nextSong:(id)sender
577 [currentRemote goToNextSong];
580 - (void)prevSong:(id)sender
582 [currentRemote goToPreviousSong];
585 - (void)fastForward:(id)sender
587 [currentRemote forward];
590 - (void)rewind:(id)sender
592 [currentRemote rewind];
595 - (void)toggleEqualizer
597 [currentRemote setEqualizerEnabled:![currentRemote equalizerEnabled]];
600 - (void)quitMenuTunes:(id)sender
602 [NSApp terminate:self];
605 - (void)showPreferences:(id)sender
607 if (!prefsController) {
608 prefsController = [[PreferencesController alloc] initWithMenuTunes:self];
613 - (void)closePreferences
615 if ( ( isAppRunning == ITMTRemotePlayerRunning) ) {
618 [prefsController release];
619 prefsController = nil;
622 - (void)showPlayer:(id)sender
624 if ( ( isAppRunning == ITMTRemotePlayerRunning) ) {
625 [currentRemote showPrimaryInterface];
627 if (![[NSWorkspace sharedWorkspace] launchApplication:[currentRemote playerFullName]]) {
628 NSLog(@"Error Launching Player");
636 //The status window methods go here!
641 - (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers
642 onItem:(NSMenuItem *)item
644 unichar charcode = 'a';
646 long cocoaModifiers = 0;
647 static long carbonToCocoa[6][2] =
649 { cmdKey, NSCommandKeyMask },
650 { optionKey, NSAlternateKeyMask },
651 { controlKey, NSControlKeyMask },
652 { shiftKey, NSShiftKeyMask },
655 for (i = 0; i < 6; i++) {
656 if (modifiers & carbonToCocoa[i][0]) {
657 cocoaModifiers += carbonToCocoa[i][1];
660 [item setKeyEquivalentModifierMask:cocoaModifiers];
662 //Missing key combos for some keys. Must find them later.
676 /*MenuRef menuRef = _NSGetCarbonMenu([item menu]);
677 NSLog(@"%@", menuRef);
678 SetMenuItemCommandKey(menuRef, 0, NO, 49);
679 SetMenuItemModifiers(menuRef, 0, kMenuNoCommandModifier);
680 SetMenuItemKeyGlyph(menuRef, 0, kMenuBlankGlyph);
686 charcode = NSDeleteFunctionKey;
702 charcode = NSF5FunctionKey;
706 charcode = NSF6FunctionKey;
710 charcode = NSF7FunctionKey;
714 charcode = NSF3FunctionKey;
718 charcode = NSF8FunctionKey;
722 charcode = NSF9FunctionKey;
726 charcode = NSF11FunctionKey;
730 charcode = NSF3FunctionKey;
734 charcode = NSF14FunctionKey;
738 charcode = NSF10FunctionKey;
742 charcode = NSF12FunctionKey;
746 charcode = NSF13FunctionKey;
750 charcode = NSInsertFunctionKey;
754 charcode = NSHomeFunctionKey;
758 charcode = NSPageUpFunctionKey;
762 charcode = NSDeleteFunctionKey;
766 charcode = NSF4FunctionKey;
770 charcode = NSEndFunctionKey;
774 charcode = NSF2FunctionKey;
778 charcode = NSPageDownFunctionKey;
782 charcode = NSF1FunctionKey;
786 charcode = NSLeftArrowFunctionKey;
790 charcode = NSRightArrowFunctionKey;
794 charcode = NSDownArrowFunctionKey;
798 charcode = NSUpArrowFunctionKey;
802 if (charcode == 'a') {
808 kchr = (Ptr) GetScriptVariable(smCurrentScript, smKCHRCache);
809 keyTrans = KeyTranslate(kchr, code, &state);
811 [item setKeyEquivalent:[NSString stringWithCString:&charCode length:1]];
812 } else if (charcode != 'b') {
813 [item setKeyEquivalent:[NSString stringWithCharacters:&charcode length:1]];