Re: rightMouseDown: never called in NSView subclass
Re: rightMouseDown: never called in NSView subclass
- Subject: Re: rightMouseDown: never called in NSView subclass
- From: Indragie Karunaratne <email@hidden>
- Date: Fri, 26 Aug 2011 16:53:02 -0600
Thank you for this tip, I had tried doing this earlier, but I was using -hitTest: from my NSWindow to find out if the event should be passed to my view, which obviously didn't work because NSToolbarView was overriding -hitTest: to return itself. I got it working by converting point to the view's local coordinates and checking whether it was within bounds. Here's the code snippet:
- (void)sendEvent:(NSEvent *)theEvent
{
switch (theEvent.type) {
case NSRightMouseDown: {
NSPoint point = [self.toolbarView convertPoint:[theEvent locationInWindow] fromView:nil];
if (NSPointInRect(point, [self.toolbarView bounds])) {
[self.toolbarView rightMouseDown:theEvent];
return;
}
[super sendEvent:theEvent];
break;
} default:
[super sendEvent:theEvent];
break;
}
}
On 2011-08-26, at 1:28 PM, Lee Ann Rucker wrote:
> What if you intercept the event a bit higher, in [NSWindow sendEvent:]?
>
> The right click gets intercepted by the toolbar view because it's got its own menu; it's likely your users won't discover your menu because they're expecting that one. I have toolbar items with menus, but they're NSButtons that show the menu on left-click. Have you considered using an NSButton and setting its image to NSImageNameActionTemplate ("An action menu template image")? That would be discoverable and accessible.
>
> (Meant to hit reply-all)
>
> On Aug 26, 2011, at 9:36 AM, Indragie Karunaratne wrote:
>
>> Thats actually what I'm doing right now, its an NSToolbarItem with a custom view but like I said, the right mouse events are not passed to it by NSToolbarView without that little hack. I could, as you said, circumvent NSToolbar completely, but when a view is placed outside of the toolbar, it disappears when Lion goes into fullscreen mode. I don't know if this is a bug or intended behaviour.
>
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please 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