Re: Not getting mouseDown: called when control-clicking in view in menu item SOLVED
Re: Not getting mouseDown: called when control-clicking in view in menu item SOLVED
- Subject: Re: Not getting mouseDown: called when control-clicking in view in menu item SOLVED
- From: Tim Hewett <email@hidden>
- Date: Sun, 18 May 2014 02:09:03 +0100
Solved.
The problem was caused by the view concerned having a menu set with setMenu:. With that remove it now gets mouseDown: with control held down.
Many thanks for your thoughts.
On 18 May 2014, at 01:44, Tim Hewett <email@hidden> wrote:
> As a test I have replaced the TrackView view with my own view in the MenuItemView sample code mentioned previously, still creating it programatically as in my own code, and it now gets mouseDown: with control held down no problem.
>
> So clearly the issue is nothing to do with how the view is created or some setting in the view class hierarchy. I suspect something to do with the way the app is started and its environment - it is created without any XIB as it is a user agent started by launchd and has no “.app” folder hierarchy, just a standalone executable which only creates a status bar menu item. It sets itself up as a delegate to NSApplication in main() and starts everything in applicationDidFinishLaunching:.
>
> The MenuItemView sample code is a more conventional Cocoa app with a XIB file etc. so maybe NSApplication (or other things) has different default settings.
>
> No obviously-related setting has been discovered in NSApplication as yet and things tried so far have made no difference.
>
>
> On 17 May 2014, at 02:46, Lee Ann Rucker <email@hidden> wrote:
>
>> NSView handles rightMouseDown: differently - it calls calls menuForEvent: Documentation says in 10.7+ it should pass it up the responder chain, so you ought to get it.
>>
>> I'd put a symbolic break on -[NSView rightMouseDown:] and see if it's being called; that might shed some light on where it's going.
>>
>>
>> On May 16, 2014, at 8:11 AM, Tim Hewett wrote:
>>
>>> I have tried that too, no message for that either.
>>>
>>> Tim.
>>>
>>>
>>> On 16 May 2014, at 14:30, Eric Shepherd <email@hidden> wrote:
>>>
>>>> Try implementing rightMouseDown: instead for that.
>>>>
>>>> Eric Shepherd
>>>>
>>>>> On May 15, 2014, at 12:39 PM, Tim Hewett <email@hidden> wrote:
>>>>>
>>>>> I have a NSMenuItem with a custom view (inheriting from NSImageView) which needs to react to mouseDown: events. An NSTrackingArea has been setup for the view’s frame to enable this.
>>>>>
>>>>> When getting the events the modifierFlags are used to change behaviour, but this doesn’t work when control is held down - no mouseDown: event occurs at all (no problem with other modifier keys).
>>>>>
>>>>> If mouseDown: is called with no modifier keys held down and then control is pressed, this can be seen in the modifier flags when the mouseUp: event occurs.
>>>>>
>>>>> The TrackView in the MenuItemView sample code has been tested and gets mouseDown: events including when control is held down, the only difference seems to be that the view in that sample is defined in a XIB while the problem code’s view is created programmatically.
>>>>>
>>>>> Is there a way that this app can get mouseDown: events when control is being held down?
>>>>> _______________________________________________
>>>>>
>>>>> 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