• 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: rightMouseDown: never called in NSView subclass
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >rightMouseDown: never called in NSView subclass (From: Indragie Karunaratne <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Kyle Sluder <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Indragie Karunaratne <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Ken Thomases <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Indragie Karunaratne <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Corbin Dunn <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Indragie Karunaratne <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Raleigh Ledet <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Indragie Karunaratne <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Quincey Morris <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Indragie Karunaratne <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Quincey Morris <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Indragie Karunaratne <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Mark Munz <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Indragie Karunaratne <email@hidden>)
 >Re: rightMouseDown: never called in NSView subclass (From: Lee Ann Rucker <email@hidden>)

  • Prev by Date: Re: Sharing a persistent store between iOS and Mac
  • Next by Date: Re: update nspopupbutton at use-time
  • Previous by thread: Re: rightMouseDown: never called in NSView subclass
  • Next by thread: Re: rightMouseDown: never called in NSView subclass
  • Index(es):
    • Date
    • Thread