Re: Non-Contextual Popup Menus using NSPopupButtonCell and attachPopupWithFrame or performClickWithFrame
Re: Non-Contextual Popup Menus using NSPopupButtonCell and attachPopupWithFrame or performClickWithFrame
- Subject: Re: Non-Contextual Popup Menus using NSPopupButtonCell and attachPopupWithFrame or performClickWithFrame
- From: Peter Ammon <email@hidden>
- Date: Tue, 8 Jan 2008 12:54:10 -0800
On Jan 8, 2008, at 6:52 AM, Oliver Kurek wrote:
Reading through the documentation regarding contextual popup menus,
Apple
notes that the prefered method of popping up a non-contextual menu
is using
an NSPopupButtonCell and using the attachPopupWithFrame:inView method.
After attempting this on my own with little luck, and browing
Google, I
found that others had issues with using
attachPopupWithFrame:inView, and
suggested to use performClickWithFrame:inView instead.
Specifically, when
using the former, no menu appears at all. With the latter, the
menu pops
up, but it does not appear at the position of the mouse pointer.
Instead,
the menu appears to popup at roughtly the right horizontal position on
screen, but always at the bottom edge of the view.
The particular situation I have is an NSTextView that is
subclassed, which
occasionally includes text formated as a link with a custom-handled
link
object. When the link is clicked, a menu is generated based on the
details
of the link and popped up.
Is there any way to have this menu pop up at the position of the mouse
pointer? Has anyone had success using attachPopupWithFrame:inView
rather
than performClickWithFrame:inView?
Any help would be greatly appreciated!
Hi Oliver,
With performClickWithFrame: inView:, the menu will pop up as if a
popup button were positioned within the frame parameter, interpreted
as a rect within the bounds coordinate space of the given view. To
pop up a menu where the user clicked, pass a 1x1 rect whose origin is
the location of the event within the bounds of your view, as the
frame parameter.
I hope that's clear,
-Peter
_______________________________________________
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