• 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: Attaching a menu to a view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Attaching a menu to a view


  • Subject: Re: Attaching a menu to a view
  • From: Ryan Stevens <email@hidden>
  • Date: Thu, 14 Nov 2002 21:59:03 -0800

On Thursday, November 14, 2002, at 01:02 PM, Yong Lee wrote:

> How do you attach a menu to a view?
>
> The view method - (NSMenu *)menuForEvent:(NSEvent *)theEvent
> or
> responder method - (void)setMenu:(NSMenu *)aMenu
>
> only seems to work when the control key is pressed (as a contextual
> menu). Is there a way for menu to appear when the view is clicked
> without a modifier key?
>

In your mouseDown try this:
[NSMenu popUpContextMenu:[self menu] withEvent:theEvent forView:self];

Alternatively you could do something with NSPopUpButton, I think. I
haven't tried toying with it but I'd bet it would be easy enough to
customize it to your liking.

Anyway, HTH! :-)
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Attaching a menu to a view (From: Yong Lee <email@hidden>)

  • Prev by Date: ControlRef
  • Next by Date: Re: Using Objective-C from Cocoa-Java code
  • Previous by thread: Attaching a menu to a view
  • Next by thread: UndoManager
  • Index(es):
    • Date
    • Thread