Which menu item called my method? & dock menu issues
Which menu item called my method? & dock menu issues
- Subject: Which menu item called my method? & dock menu issues
- From: Adam Iser <email@hidden>
- Date: Mon, 3 Dec 2001 20:27:00 -0500
Hi all,
I've got a menu that contains a list of pre-defined messages. Since the
list is variable, I need some way to dynamically know which menu item
was selected.
Currently, I'm using the 'sender' argument of my action method. So I
have
-(void)menuItemSelected:(id)sender{
NSLog(@"selected = %@",[(NSMenuItem*)sender title]);
}
This works (successfully printing out the selected menu item's title)...
but is it the best way?
Okay - now onto my application's dock menu... I'd like to have the same
setup down there (with a list of pre-defined messages for easy
picking). But when an item is selected from my dock menu, an instance
of NSApplication is passed in the sender argument... whoops! :)
So how should I go about handling a dynamic list in the dock menu? Am I
missing something simple here?
-Adam Iser
BTW I'm still having issues finding a way to determine the system's idle
time (how long it's been since the user typed or moved the mouse). I
tried a class dump of loginWindow - but didn't find much besides a
private variable and a few functions that didn't look right (if I could
figure out how to use a class that isn't in a framework maybe I could
check ;P) - I also got some help in the form of a CGS function -
unfortunately that doesn't work if the system is set to never sleep (it
appears). Really frustrating stuff! I'm debating putting up a dialog
that has to be clicked every 46 minutes or my app will assume you're
idle... ;P - hey, it works for AOL! ;)
-Adam Iser
http://homepage.mac.com/adamiser/
http://www.adiumx.com