• 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
Re: NSToolbarItem Action Not Passed to NSButton...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: NSToolbarItem Action Not Passed to NSButton...
      • From: Andy Lee <email@hidden>
References: 
 >NSToolbarItem Action Not Passed to NSButton... (From: "Peters, Brandon" <email@hidden>)
 >Re: NSToolbarItem Action Not Passed to NSButton... (From: Andy Lee <email@hidden>)
 >Re: NSToolbarItem Action Not Passed to NSButton... (From: "Peters, Brandon" <email@hidden>)
 >Re: NSToolbarItem Action Not Passed to NSButton... (From: Andy Lee <email@hidden>)
 >Re: NSToolbarItem Action Not Passed to NSButton... (From: "Peters, Brandon" <email@hidden>)
 >Re: NSToolbarItem Action Not Passed to NSButton... (From: Andy Lee <email@hidden>)

  • Prev by Date: how to disable "ARM function not 4-byte aligned" warning?
  • Next by Date: Re: GCD killed my performance
  • Previous by thread: Re: NSToolbarItem Action Not Passed to NSButton...
  • Next by thread: Re: NSToolbarItem Action Not Passed to NSButton...
  • Index(es):
    • Date
    • Thread