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

popUpContextMenu interfering with mouseUp


  • Subject: popUpContextMenu interfering with mouseUp
  • From: Oliver Cameron <email@hidden>
  • Date: Mon, 8 Nov 2004 17:09:36 +0000

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.


Any ideas appreciated,
Thanks,
Oliver

_______________________________________________
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


  • Follow-Ups:
    • Re: popUpContextMenu interfering with mouseUp
      • From: "M. Uli Kusterer" <email@hidden>
    • Re: popUpContextMenu interfering with mouseUp
      • From: Andreas Mayer <email@hidden>
  • Prev by Date: Re: Why does NSBundle's load fail?
  • Next by Date: Re: popUpContextMenu interfering with mouseUp
  • Previous by thread: Re: Why does NSBundle's load fail?
  • Next by thread: Re: popUpContextMenu interfering with mouseUp
  • Index(es):
    • Date
    • Thread