popUpContextMenu interfering with mouseUp
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