• 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: popUpContextMenu interfering with mouseUp
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: popUpContextMenu interfering with mouseUp


  • Subject: Re: popUpContextMenu interfering with mouseUp
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Tue, 9 Nov 2004 00:56:54 +0100

At 17:09 Uhr +0000 08.11.2004, Oliver Cameron wrote:
Hi guys,

I'm creating an almost NSPopUpButton replica, but I wanted to start from scratch and create a NSView. So basically, what I do on mouseDown, is open a menu, this is the code I use:

- (void)menuShouldOpen
{
NSPoint viewLocation = [self frame].origin;
viewLocation.y = viewLocation.y + 12;
[NSMenu popUpContextMenu:objectMenu withEvent:[NSEvent mouseEventWithType:NSLeftMouseDown location:viewLocation modifierFlags:0 timestamp:1 windowNumber:[[NSApp mainWindow] windowNumber] context:[NSGraphicsContext currentContext] eventNumber:1 clickCount:1 pressure:0.0] forView:self];
}


- (void)mouseDown:(NSEvent *)event
{
[self setPressed:YES];
[self setNeedsDisplay:YES];
[self performSelector:@selector(menuShouldOpen)];
}

- (void)mouseUp:(NSEvent *)event
{
[self setPressed:NO];
[self setNeedsDisplay:YES];
}

Now, the menu shows up fine and the NSView is 'pressed', so basically, I want when the mouse goes up, for the menu to basically disappear and for the NSView to go back to not being 'pressed'. This doesn't seem to be happening, but if I take away the NSMenu popUpContextMenu, I get the correct behaviour I am looking for. The only thing I can suspect is that the NSEvent for the window popping up is somehow cancelling out the event for mouseUp.

Yes, that's because the mouseUp is actually happening over the menu, so logically the menu gets the mouseUp message, not your button.


Have you tried doing the things you do in mouseUp at the end of mouseDown instead? I think popUpContextMenu blocks, doesn't it? That should be better, especially since you can also pop up a menu with one click, and select the menu item with a second click. In that case, if your view got the mouseUp event, it would unhighlight immediately after showing the menu, which probably isn't what you want.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >popUpContextMenu interfering with mouseUp (From: Oliver Cameron <email@hidden>)

  • Prev by Date: Re: $10 for a few [hours?] work
  • Next by Date: Re: $10 for a few [hours?] work
  • Previous by thread: Re: popUpContextMenu interfering with mouseUp
  • Next by thread: [Re-post] Cell selection and scrolling
  • Index(es):
    • Date
    • Thread