Re: NSToolbarItem Action Not Passed to NSButton...
Re: NSToolbarItem Action Not Passed to NSButton...
- Subject: Re: NSToolbarItem Action Not Passed to NSButton...
- From: "Peters, Brandon" <email@hidden>
- Date: Fri, 25 Apr 2014 05:23:54 +0000
- Thread-topic: NSToolbarItem Action Not Passed to NSButton...
I tried and nothing. The IBOutlet is on the NSToolbarItem custom class. Here is my custom class:
@interface RBSStopButtonToolbarItem : NSToolbarItem
{
NSButton *_button;
}
@property (readwrite) NSButton *button;
@end
@implementation RBSStopButtonToolbarItem
@synthesize button = _button;
-(id)initWithItemIdentifier:(NSString *)itemIdentifier
{
self = [super initWithItemIdentifier:itemIdentifier];
if(self)
{
// set min and max size
[self setMinSize:NSMakeSize(32.0, 32.0)];
[self setMaxSize:NSMakeSize(32.0, 32.0)];
NSLog(@"Self: %@", self);
}
return self;
}
-(void)validate
{
NSLog(@"Validate called...");
// set the original and alternate images...names are "opposite"
_button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 32, 32)];
//[_button setFrameSize:NSMakeSize(32.0, 32.0)];
NSImage *image = [NSImage imageNamed:@"StopButtonAlternateIcon"];
[image setSize:NSMakeSize(32.0, 32.0)];
[_button setImage:image];
image = [NSImage imageNamed:@"StopButtonIcon"];
[image setSize:NSMakeSize(32.0, 32.0)];
[_button setAlternateImage:image];
// image position
[_button setImagePosition:NSImageOnly];
// set button type
[_button setButtonType:NSToggleButton];
// button is transparent
[_button setBordered:NO];
// set the toolbar item view to the button
[self setView:_button];
}
@end
The images will display, but the action does not seem to “connect”, even though it is done in IB.
On Apr 24, 2014, at 11:47 PM, Andy Lee <email@hidden<mailto:email@hidden>> wrote:
On Apr 24, 2014, at 11:15 PM, "Peters, Brandon" <email@hidden<mailto:email@hidden>> wrote:
My button is inside the customer toolbar item, if I make the button an outlet, how will I connect to it in IB?
You can do it in code when you set it up. See setAction: and setTarget:.
I don't know for sure if that'll work -- it's the only guess I can come up with.
--Andy
_______________________________________________
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