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: Thu, 25 Aug 2011 18:05:58 -0600
This would make more sense if I explained what the view itself was. Long story short, it's a pretty huge (and important) custom control that runs all the way across the toolbar. There are other ways to access the commands (via the application menus + shortcuts) but I would also like to have a contextual menu.
On 2011-08-25, at 4:52 PM, Raleigh Ledet wrote:
> A contextual menu in a toolbar? Lets think about this for a moment.
>
> A) such a command would be hard to discover. Your customers have other ways to activate the same commands right? If not, why not use a popup button here?
> B) I assume that's because you have an action tied to single click…. why not look for a click and hold, then pop-up a menu a' la Safari's back/forward tool bar buttons. Oh! and users have an alternate way to get to these actions / settings right?
>
> -raleigh
>
> On Aug 25, 2011, at 3:39 PM, Indragie Karunaratne wrote:
>
>> I just need to present a contextual menu from my custom view toolbar item, but NSToolbarView is not passing the right mouse events down, so -menuForEvent: is never called.
>>
>> On 2011-08-25, at 4:27 PM, Corbin Dunn wrote:
>>
>>> ToolbarView overrides hitTest; to do some magic; that is probably the source of your problem.
>>>
>>> What are you trying to do?
>>>
>>> corbin
>>>
>>> On Aug 25, 2011, at 3:14 PM, Indragie Karunaratne wrote:
>>>
>>>> Just realized something interesting, and remembered a key detail that I forgot to mention. The view in question is a custom view inside the toolbar of the window. The NSToolbar by default has a contextual menu that appears when the customizable property is set to YES. However, even though there is no menu when customizable is set to NO, I suspected that it was still trapping right mouse events. So I used a category on the private NSToolbarView class that manages the UI for NSToolbar to check whether it was receiving the events:
>>>>
>>>> @interface NSToolbarView : NSView
>>>> @end
>>>>
>>>> @interface NSToolbarView (RightMouse)
>>>> @end
>>>>
>>>> @implementation NSToolbarView (RightMouse)
>>>>
>>>> - (void)rightMouseDown:(NSEvent*)theEvent
>>>> {
>>>> NSLog(@"right mouse");
>>>> }
>>>>
>>>> @end
>>>>
>>>> And as expected, the method is called. This leaves me wondering how the toolbar view can receive the events when my own view inside the toolbar can not (as the event would have to be forwarded up the responder chain to the toolbar in order for it to receive it).
>>>>
>>>> On 2011-08-25, at 1:58 PM, Ken Thomases wrote:
>>>>
>>>>> On Thu, Aug 25, 2011 at 11:45 AM, Indragie Karunaratne <email@hidden> wrote:
>>>>>
>>>>>> I have an NSView subclass that I'm trying to capture right clicks in. I override the rightMouseDown: method but it is never called.
>>>>>
>>>>> Any chance you simply have a typo or misspelling in your method signature?
>>>>>
>>>>> -Ken
>>>>>
>>>>
>>>> _______________________________________________
>>>>
>>>> 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
>>>
>>
>> _______________________________________________
>>
>> 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
>
_______________________________________________
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