• 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
Questions for implementing pop-up contextual menus for Ctrl-Click and Right-Click
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Questions for implementing pop-up contextual menus for Ctrl-Click and Right-Click


  • Subject: Questions for implementing pop-up contextual menus for Ctrl-Click and Right-Click
  • From: "E. Wing" <email@hidden>
  • Date: Tue, 21 Nov 2006 15:31:50 -0800

I have a custom view in which I am trying to implement a popup
contextual menu via Ctrl-Click or Right-Click.

I thought I had to handle all this myself, so I had already refactored
my mouseDown and rightMouseDown events to filter into common methods.
In mouseDown, I detect if the Ctrl button is pressed and invoke my
desired common method. In this common method, I call
popUpContextMenu:withEvent:forView:

I later discovered that if I override menuForEvent:, then the
Ctrl-Click brings up the the contextual menu. But it doesn't handle
the right-click.


So my first question is, does it matter which approach I take to do this? How bad is it to not implement the menuForEvent: and continue along my current path? I would rather not undo the code refactoring I did. I presume that having both menuForEvent: and calling popUpContextMenu:withEvent:forView: on Ctrl-Click would not be good because it is redundant.

My second question is, how can I detect if the popup contextual menu
is currently open? The reason I want to know is if the menu is open,
and I decide to left-click outside the menu to cancel, my view may
receive the mouseDown event and does it's normal left-click action. I
would prefer not to perform the action in this case and make it a
no-op.

Thanks,
Eric
_______________________________________________

Cocoa-dev mailing list      (email@hidden)

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


  • Follow-Ups:
    • Re: Questions for implementing pop-up contextual menus for Ctrl-Click and Right-Click
      • From: "Alan Smith" <email@hidden>
  • Prev by Date: Re: External kill of an NSThread?
  • Next by Date: NSStatus item from background / command line application
  • Previous by thread: Re: selection drag within nsview
  • Next by thread: Re: Questions for implementing pop-up contextual menus for Ctrl-Click and Right-Click
  • Index(es):
    • Date
    • Thread