Skip navigation.
 
mlNew to Cocoa - Action Buttons
FROM : Alan Francis
DATE : Thu Oct 07 21:25:54 2004

Hi,

I posted this to the xcode list (it seemed the right place) and got
nothing in the way of response (not even a hello) so I wondered if the
cocoa list might be able to help...

----
Hi,

I'm a reasonably experienced (10+yrs) C/C++/Java programmer but I just
got my first Mac and have started playing with Cocoa and XCode.

Something (random) I'm having a bit of trouble with is trying to
implement the context-sensitive "action" button, a la finder/mail etc.

I kind of expected it to be available in IB palettes since it seems to
be a pretty standard UI feature now, but it isn't there...  On closer
inspection it's obviously hand-rolled in all the apps I've seen that
have it (some using ordinary toggle NSButtons, other using
NSPopupButton), the only thing that's standard is the 'cog' graphic.

So...assuming I'm hand-rolling my own...

* I have a toggle button created and two graphics 'borrowed' from
  another app for the button in it's normal and depressed states.
* I have a context menu created in IB
* I can hook the menu up to the button (using the menu outlet) so
  it triggers when I right-click (ctrl-click).

However, I can't work out how to pop a menu up, in a specific place (ie
underneath the button, left-aligned), when I left-click (click?) the
button ?

Can anyone point me at some sample code ?

Thanks in advance,

Alan.

--
Alan C Francis
http://www.twelve71.com/
http://www.thoughtworks.com/

--
Alan C Francis
http://www.twelve71.com/
http://www.thoughtworks.com/

Related mailsAuthorDate
No related mails found.