> Date: Tue, 24 Mar 2009 07:47:47 +0000 > From: Benjamin Dobson <importedfromsp...@googlemail.com> > Subject: Re: Simulating (or obtaining) menubar effect in a Cell
> In what way does NSPopUpButtonCell act incorrectly? It seems to work > for me, but obviously, I don't know exactly what your target is. I am trying to simulate an NSStatusItem that is just a square (18x18) icon. Using an NSPopUpButtonCell at that size gives only the arrows indicating the pop-up. As far as I can tell, there is no way to "setImage" for an NSPopUpButtonCell -- the documentation for "setImage" in NSPopUpButtonCell states: <quote>This method has no effect. The image displayed in a pop up button is taken from the selected menu item (in the case of a pop up menu) or from the first menu item (in the case of a pull-down menu).</quote> I am creating a statusItem that puts a matrix of small buttons in the menu bar. I would like one of those buttons to behave as if it was a standard NSStatusItem (just an icon that acts as a menu), but I want to keep it in the matrix so it doesn't get separated from the other buttons (i.e., I don't want to create a separate statusItem). I have gotten pretty close with NSButtonCell using NSMomentaryChangeButton, setting an alternative image, and setting the action to a method that calls "popUpStatusItemMenu" on the whole matrix (or, more precisely, on the statusItem that has its view set to be the matrix). The non-menuish behaviors that remain are (1) the highlight color is grey, not the system standard, which on my system is blue; (2) calling "popUpStatusItemMenu" causes the menu to be attached to (and as wide as) the whole matrix, (which I can live with, but it isn't standard), and (3) mouse tracking still works differently from regular menus (i.e., menu opens on mouseup instead of mousedown, and therefore does not close on mouseup when the mouse button is held down). On #1, I see that NSCell has a method highlightColorWithFrame:inView, which sounds promising, but I have yet to find a method that sets the highlight color for a cell. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com