• 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
[SOLVED] popup menus at a specified position
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SOLVED] popup menus at a specified position


  • Subject: [SOLVED] popup menus at a specified position
  • From: Cristian Savu <email@hidden>
  • Date: Mon, 11 Nov 2002 09:25:21 +0200

Hy there,
There were several threads talking about displaying menus wherever somebody wants.
Cocoa doesn't provide us a direct solution, but there is an easy workaround (it took me a while to figure out about this:( ).
This could be also a solution for context menus.

// create a fake event (NSLeftMouseDown) to send it as a base for pop-up menu.
NSEvent *theEvent= [NSEvent
mouseEventWithType:NSLeftMouseDown
location:NSMakePoint(200,200)
modifierFlags:0
timestamp:1
windowNumber:[[NSApp mainWindow] windowNumber]
context:[NSGraphicsContext currentContext]
eventNumber:1
clickCount:1
pressure:0.0];

//and now pop the menu
[NSMenu popUpContextMenu: [NSApp mainMenu] withEvent:theEvent forView: aView];

Good luck !

Cristian
_______________________________________________
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.

  • Prev by Date: Having troubles implementing categories
  • Next by Date: [OT] Marketing advice
  • Previous by thread: Re: Having troubles implementing categories
  • Next by thread: [OT] Marketing advice
  • Index(es):
    • Date
    • Thread