Re: keyboard focus handling in custom controls
Re: keyboard focus handling in custom controls
- Subject: Re: keyboard focus handling in custom controls
- From: Ken Thomases <email@hidden>
- Date: Mon, 10 Sep 2018 11:20:24 -0500
>> On 10 Sep 2018, at 13:21, iain <email@hidden
>> <mailto:email@hidden>> wrote:
>>>
>>> I have an application, which has 3 controls
>>>
>>> [button] [custom view] [button]
>>>
>>> I’ve set the NextKeyView of each of them to the control to the right
>>> [button] -> [custom view] -> [button]
>>>
>>> And the tab and shift tab works between them as expected.
>>>
>>> The situation gets more complicated because the custom view has 3 possible
>>> focus areas, which I also want to be part of the tab chain.
>>> As it’s one big custom drawn widget, I’ve implemented a rudimentary tab
>>> handler in the KeyDown: method with a counter to keep track of which area
>>> is focused.
>>> And it sort of works
>>>
>>> But, I’m wondering how to know if the parent NSView gained keyboard focus
>>> through a tab or a shift-tab
>>>
>>> If focus is on the first button, and you press Tab, the focus should go to
>>> the 1st area of the custom view
>>> If focus is on the last button and you Shift Tab from it, the focus should
>>> go to the 3rd area of the custom view
>>> Currently, it always has to go to the area that was focused when the view
>>> lost focus.
>>>
>>> Is there a way to do what I’m wanting?
I haven't tried it, but have you considered implementing
-select{Next,Previous}KeyView: on your view. If you're staying within your
view, don't call through to super. Otherwise, do, which will pass it up the
responder chain to the window, which will do the normal thing. (Or, you could
reimplement what the window would do using
-selectKeyView{Following,Preceding}View:.)
Regards,
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