Re: Hot to move focus to a button?
Re: Hot to move focus to a button?
- Subject: Re: Hot to move focus to a button?
- From: Ricky Sharp <email@hidden>
- Date: Sun, 7 Mar 2010 06:21:03 -0600
On Mar 7, 2010, at 3:53 AM, Joanna Carter wrote:
> Hi Kyle
>
>> Buttons don't accept keyboard focus. See the documentation for
>> -[NSView canBecomeKeyView] and the related conceptual documentation.
>
> I realise this to be what the docs say but, if you use -makeFirstResponder: the focus ring is applied to the chosen button and pressing the spacebar calls the connected action, which is, surely, the desired end result of "setting focus".
All you need to do is properly set up the key view loop in IB. i.e. connect the 'nextKeyView' outlets.
If your UI is something like this:
Prompt: [edit field]
(button1) (button2)
set 'nextKeyView' of 'edit field' to 'button1'. Then, 'button1' to 'button2' and finally 'button2' back to the 'edit field'.
Also, ensure to set the first responder as needed.
When Full Keyboard Access is off, users will only be able to tab amongst controls that are text boxes or lists. Otherwise, when on, they will be able to tab amongst all controls.
You should get automatic behavior 99% of the time (i.e. you never have to call makeFirstResponder: manually). There are cases where you need to do so when you have very complex UI involving tabless tabviews (usually nested). In response to selected tab changes, you can "rewire" the keyloop manually as needed and re-establish the current control that should have focus.
___________________________________________________________
Ricky A. Sharp mailto:email@hidden
Instant Interactive(tm) http://www.instantinteractive.com
_______________________________________________
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