• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Which menu item called my method? & dock menu issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Which menu item called my method? & dock menu issues
      • From: "Clark S. Cox III" <email@hidden>
  • Prev by Date: Re: How to clear the contents of a StringHandle?
  • Next by Date: Re: print OpenGLView
  • Previous by thread: Re: create a image from a NSString or NSView.
  • Next by thread: Re: Which menu item called my method? & dock menu issues
  • Index(es):
    • Date
    • Thread