Re: Improving NSStatusItem awareness
Re: Improving NSStatusItem awareness
- Subject: Re: Improving NSStatusItem awareness
- From: Jeffrey Mattox <email@hidden>
- Date: Wed, 7 May 2003 15:49:40 -0500
Conversely, if you do not attach a menu to the status menu item, then
you can have it trigger a Cocoa method when it is clicked.
NSStatusItem *theStatusBarItem;
- (void)activateStatusMenu
{
NSLog(@"activateStatusMenu\n");
NSStatusBar *bar = [NSStatusBar systemStatusBar];
theStatusBarItem = [bar statusItemWithLength:NSVariableStatusItemLength];
[theStatusBarItem retain]; // else the menu item just flashes on
[theStatusBarItem setTitle:@"TEST"];
[theStatusBarItem setHighlightMode:YES];
[theStatusBarItem setAction:@selector(menuClicked:)];
[theStatusBarItem sendActionOn:NSLeftMouseDownMask];
return;
}
- (void)menuClicked:(NSObject *)theStatusBarButton
{
NSLog(@"menuClicked %@\n",theStatusBarButton);
}
- (void)removeStatusMenu
{
NSLog(@"removeStatusMenu\n");
NSStatusBar *bar = [NSStatusBar systemStatusBar];
[bar removeStatusItem:theStatusBarItem];
// [theStatusBarItem release]; // because we retained it, but crashes
return;
}
(Maybe somebody can explain the crash when the menu item is released.)
Jeff
At 9:52 AM +0300 5/7/03, Dan Bernstein wrote:
If your status item has a menu, then whenever it's clicked, it sends
a menu item validation message for each item to that item's target.
-- Dan
On Wednesday, May 7, 2003, at 04:07 AM, Kent Sutherland wrote:
Is there a way for me to be able to subclass or change NSStatusItem
in order for it to send messages whenever it is clicked on, similar
to NSMenuExtra and it's -menu method? I've tried doing all kinds of
thing with _button and _button's cell to no avail. I've also tried
subclassing it and overriding lots of methods, but nothing seems to
work.
Has anyone else gotten NSStatusItem to call a method when it's clicked on?
Kent Sutherland
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.