Re: addTarget: forControlEvents: ?
Re: addTarget: forControlEvents: ?
- Subject: Re: addTarget: forControlEvents: ?
- From: Dave <email@hidden>
- Date: Fri, 10 Apr 2015 12:05:52 +0100
Thanks a lot for this Uli, it’s been so long since I’ve worked on Cocoa/Mac that I’d forgotten how different it is from iOS.
I hadn’t thought about the difference between Mouse and TrackPad thanks for reminding me.
All the Best
Dave
> On 8 Apr 2015, at 14:19, Uli Kusterer <email@hidden> wrote:
>
> On 07 Apr 2015, at 21:49, Dave <email@hidden> wrote:
>> Given the iOS/Cocoa-Touch code:
>>
>> [self addTarget:self action:@selector(buttonTouchUpInsideAction:) forControlEvents:UIControlEventTouchUpInside];
>> [self addTarget:self action:@selector(buttonTouchDownAction:) forControlEvents:UIControlEventTouchDownInside];
>
> I presume you mean to react both to mouseDown and mouseUp events? Not touch gestures on the trackpad? You'd have to subclass NSButton and override NSResponder's mouseDown: and mouseUp: methods. buttons on OS X support neither multiple target/action pairs on one object, nor do they let you control when they send their action. They will always send it on a mouseUp: with the mouse inside the button.
>
> Whatever you do, also keep in mind that full keyboard access and accessibility (the latter also on iOS) let you trigger buttons without using the mouse, so if you assume your mouseUp: action will always trigger after a mouseDown:, you may get a surprise with users who trigger them without the mouse (e.g. by tabbing and using the space key, or pressing the return key to trigger a default button).
_______________________________________________
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