Re: NSMenuItem / NSMenu Problems
Re: NSMenuItem / NSMenu Problems
- Subject: Re: NSMenuItem / NSMenu Problems
- From: Jeremy <email@hidden>
- Date: Thu, 10 Jan 2008 16:50:01 -0500
Thanks for your help! I am having some problems with both things, sadly.
Using +[NSMenuItem separatorItem] is giving me two build errors: wrong
type argument to unary plus...
Also, the program stalls when opening. Here's the code where this is
being used:
// iTunes Controls
+[NSMenuItem separatorItem];
seven = [menu addItemWithTitle:@"iTunes Controls" action:nil
keyEquivalent:@""];
[menu setSubmenu:subMenu forItem:seven];
sOne = [subMenu addItemWithTitle:@"Next Song"
action:@selector(skipTrack:) keyEquivalent:@""];
[sOne setTarget:self];
sTwo = [subMenu addItemWithTitle:@"Previous Song"
action:@selector(backTrack:) keyEquivalent:@""];
sThree = [subMenu addItemWithTitle:@"Beginning of Current Song"
action:@selector(beginning:) keyEquivalent:@""];
sFour = [subMenu addItemWithTitle:@"Play/Pause Current Song"
action:@selector(playPause:) keyEquivalent:@""];
sFive = [subMenu addItemWithTitle:@"Quit iTunes"
action:@selector(quitItunes:) keyEquivalent:@""];
Thanks for the help!
On Jan 9, 2008, at 7:27 PM, John Stiles wrote:
For the first, use +[NSMenuItem separatorItem].
For the second, make a method inside your class. e.g.:
-(void) doMyThing:(id)sender {
// whatever
}
And then use action:@selector(doMyThing:) to hook it up. You'll also
need to use setTarget: and point it at your class.
Jeremy wrote:
I have been programming in Cocoa for not a long time. It really
isn't doing the best... for me right now. Here is my NSMenu problems:
Within my application, Tune-A-Holic, up until now I have been using
it only to retrieve the information from iTunes and display it. The
only function I have used is updateData: which was called within an
NSDistributedNotifications call. My menu problems lie within
expanding the application to have the ability to control iTunes
from the menu.
My first problem lies within separation. I would like to separate
any control items and non-information items from the information
that is displayed at the beginning of the drop down. The look I
want can be found within the Apple menu between Mac OS X Software
and System Preferences. I have found no reference to a function to
do this within NSMenu.
My second problem lies within the fact that I want to control
iTunes. It is another adventure within Scripting Bridge that I want
to mess with. Here is the problem I am having:
sOne = [subMenu addItemWithTitle:@"Item" action:nil
keyEquivalent:@""];
I can't figure out how to use the action: part of this line. The
NSMenu class reference mentions that this must be a selector, so I
used @selector() but that doesn't seem to work.
Any help on either issue would be greatly appreciated.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden