• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Non-Contextual Popup Menus using NSPopupButtonCell and attachPopupWithFrame or performClickWithFrame
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >Non-Contextual Popup Menus using NSPopupButtonCell and attachPopupWithFrame or performClickWithFrame (From: "Oliver Kurek" <email@hidden>)

  • Prev by Date: Re: NSTreeController selectedObjects always returns top level object
  • Next by Date: NSTextField syle undo manager with NSTextView?
  • Previous by thread: Non-Contextual Popup Menus using NSPopupButtonCell and attachPopupWithFrame or performClickWithFrame
  • Next by thread: Debugging a NibLoad binding error
  • Index(es):
    • Date
    • Thread