• 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
Simulate Context Menu with Window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Simulate Context Menu with Window


  • Subject: Simulate Context Menu with Window
  • From: Philip Dow <email@hidden>
  • Date: Thu, 23 Nov 2006 17:18:12 +0100

Hi all,

I'm trying to simulate the effect achieved by NSMenu's +popUpContextMenu:withEvent:forView: with a window. What's unique about this method is that it doesn't seem to return until an item is selected from the menu or a mouse down or app event occurs somewhere else. It's that latter part I'm interested in.

I can run a modal window inside a method to prevent that method from returning, but then events outside the window aren't received. Like the popup menu, I'd like the window to go away when an event occurs outside it.

I'm currently just putting a window on the screen and having mouseDown, resignKeyWindow and resignMainWindow at the window level close the window. The problem is that showWindow returns, something I'd like to avoid.

What's the point? When you pop a menu, say in response to a button going down, the button remains down while the menu is running. I'd also like the button to remain down while this window is running.

Aside from a modal loop I also tried a for loop and a few NSRunLoop calls, but I couldn't get anything working there. The app hung inside the for loop I had constructed, running the currentRunLoop until a cetain date or until input without every breaking. I think this is in the right direction, but I can't get my head around it.

Anyone have some example code or can anyone throw some light on the run loop stuff.

-Phil

PS: I had tried variations on:

for (;;) {
if ( ![[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]] )
break;
}
_______________________________________________


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


  • Prev by Date: Re: Safely cancelling modifications
  • Next by Date: Re: How to set the color of a string on a NSButton?
  • Previous by thread: Re: Rendering strokes without using NSBezierPath
  • Next by thread: NSProgressIndicator drawing
  • Index(es):
    • Date
    • Thread