Reuse Carbon custom menu in Cocoa window with PopUpMenuSelect()?
Reuse Carbon custom menu in Cocoa window with PopUpMenuSelect()?
- Subject: Reuse Carbon custom menu in Cocoa window with PopUpMenuSelect()?
- From: Jeffrey Johnson <email@hidden>
- Date: Mon, 17 Apr 2006 17:07:51 -0400
Hello all,
I need to duplicate a UI element from one of our Carbon applications that shows
a custom Carbon menu via PopupMenuSelect() in a new Cocoa app. (it's a rather
gnarly Quartz-drawn periodic table menu).
I started by bringing over our Carbon CreateCustomMenu() implementation file,
stuffed a square button into a Cocoa nib window with a Obj-C button action that
called PopUpMenuSelect(100,100,menu), and just tried it. Imagine my surprise
when the "hard part" nearly worked - it appeared (after mouseup on the button)
and returned the correct menu choice id!
Now I need to get it to "really" work- I need to do the following:
1) feed the proper coordinates to PopupMenuSelect()
I want to use the lower right point of the NSButton and convert it to the global
Carbon screen coordinates PopupMenuSelect() needs. Could someone give me a
snippet of the most efficient way to get from the Cocoa frame of the button to
QD screen coords?
BTW, There's no initial choice set on this menu- the user has to drag to the
proper choice, or to empty space and release to cancel. The title of the button
is set to the textual result of the menu choice (two letter element symbol).
2) call PopupMenuSelect() at mousedown time instead of at the "normal action"
time (mouseup)
I don't see a simple way of getting called at mouseDown: for the button without
subclassing NSButton. Usually when I come to this conclusion I've missed a
delegate hook or something- i.e. this seems like overkill. What am I missing?
Thanks
Jeffrey Johnson
Macintosh Development
Wavefunction, Inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden