Re: addTarget: forControlEvents: ?
Re: addTarget: forControlEvents: ?
- Subject: Re: addTarget: forControlEvents: ?
- From: Uli Kusterer <email@hidden>
- Date: Wed, 08 Apr 2015 15:19:18 +0200
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).
Cheers,
-- Uli
_______________________________________________
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