Re: NSToolbarItem view set to NSButton view, but not showing...
Re: NSToolbarItem view set to NSButton view, but not showing...
- Subject: Re: NSToolbarItem view set to NSButton view, but not showing...
- From: "Peters, Brandon" <email@hidden>
- Date: Thu, 24 Apr 2014 01:16:52 +0000
- Thread-topic: NSToolbarItem view set to NSButton view, but not showing...
Andy,
I discovered something that may lead to the real culprit. Using the debugger, I checked the size of the image chosen by imageNamed method, it was choosing the 128x128 icon image, but my toolbar item buttons were 48x48. I changed the toolbar item sizes to 32x32, same thing.
On Apr 23, 2014, at 9:12 PM, Andy Lee <email@hidden<mailto:email@hidden>> wrote:
Oh well, it was worth a try, and at least you've confirmed some basic steps *are* working.
From your previous message it sounds like you also checked self.toolbarItem and it too was not nil (as it could have been if, for example, you'd forgotten to connect an outlet in IB -- or if you were trying to plug in the button during init, which is too early).
If I understand what Jerry was getting at, you might want to log the addresses of the toolbar item and the button, and at some later point in the program confirm everything's still where you think it is. For example, you could put a breakpoint in the toolbar item's action method and look at sender. (I *think* that makes sense, but it might not; I haven't made a toolbar in long time.)
As a really trivial sanity check, maybe instead of setting the image, you could set the title. If you still have the problem, at least you know it's not related to setting the image.
--Andy
On Apr 23, 2014, at 8:47 PM, "Peters, Brandon" <email@hidden<mailto:email@hidden>> wrote:
Andy,
I inserted code to check for nil images and image position, here is what I got:
// set the original and alternate images...names are āopposite"
NSImage *image = [NSImage imageNamed:@"StopButtonAlternateIconā];
if(image)
{
NSLog(@"Setting 1st image for stop button");
[_button setImage:image];
}
else
{
NSLog(@"Image is null for StopButtonAlternateIcon");
}
image = [NSImage imageNamed:@"StopButtonIcon"];
if(image)
{
NSLog(@"Setting 2nd image for stop button");
[_button setAlternateImage:image];
}
else
{
NSLog(@"Image is null for StopButtonIcon");
}
// image position
[_button setImagePosition:NSImageOnly];
NSLog(@"Image position: %lu", [_button imagePosition]);
From the console:
2014-04-23 20:41:18.394 3D Rolling Ball Simulator[6321:303] Setting 1st image for stop button
2014-04-23 20:41:18.395 3D Rolling Ball Simulator[6321:303] Setting 2nd image for stop button
2014-04-23 20:41:18.395 3D Rolling Ball Simulator[6321:303] Image position: 1
On Apr 23, 2014, at 7:59 PM, Andy Lee <email@hidden<mailto:email@hidden>> wrote:
On Apr 23, 2014, at 6:36 PM, Jerry Krinock <email@hidden<mailto:email@hidden>> wrote:
On 2014 Apr 23, at 15:13, Peters, Brandon <email@hidden<mailto:email@hidden>> wrote:
call [toolbaritem setView:view] and pass in the NSButton.
Try some bonehead debugging with NSLog(). Verify that toolbaritem is your target item at that point, in particular, that it is not nil.
Two more things you can easily check:
* [NSImage imageNamed:imageName] is not returning nil.
* What is your button's imagePosition? If it's NSNoImage that might explain it.
--Andy
_______________________________________________
Cocoa-dev mailing list (email@hidden<mailto: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<http://lists.apple.com/>
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden<mailto: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