Re: Setting image one pulldown popup button
Christiaan Hofman <[email protected]>
| Newsgroups | gmane.comp.macosx.devel |
|---|---|
| Message-ID | <[email protected]> |
On Dec 7, 2009, at 14:02, Hamish Allan wrote: > On Mon, Dec 7, 2009 at 12:12 AM, Christiaan Hofman <[email protected]> wrote: >> >> On Mon, Dec 7, 2009 at 1:04 AM, Matt Neuburg <[email protected]> wrote: >>> >>> But what happens if you use *exactly* the same code as the sample code - >>> namely, the sample code itself? >> >> This is the code I use: >> >> overflowButton = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(0, 0, 17, 10) pullsDown:YES]; >> [overflowButton setBordered:NO]; >> [[overflowButton cell] setArrowPosition:NSPopUpNoArrow]; >> [[overflowButton cell] setAltersStateOfSelectedItem:NO]; >> [[overflowButton cell] setBackgroundStyle:NSBackgroundStyleRaised]; >> [overflowButton addItemWithTitle:@""]; >> [[overflowButton itemAtIndex:0] setImage:[NSImage imageNamed:@"Overflow"]]; > > That's not the code you use; that's a fragment of the code you use. The relevant part. The only line I did not draw is the one that adds it to its superview, which really is trivial. > > Like Matt says -- "what happens if you use *exactly* the same code as > the sample code - namely, the sample code itself?" > > What happens when you download the MenuMadness sample code, build and > run it without making any changes? > > H I do get the image with the sample code, now. However, the sample code does not have a popup like I have, without border and only an image. That still does not work. Also I found out that apparently something has changed in a recent OS update. There was another popup button I had that never worked (one with a border, though with a round textured bezel) but for which I can now get the image using code. A while back I had tried everything to get the image and it never worked (you can be assured I was thorough, I am not as stupid as Matt implies, and I definitely tried the straightforward single line of code that now works). But for the borderless popup with the above code I still don't get an image. Christiaan