> On 10 Sep 2018, at 2:19 pm, Alastair Houghton <alast...@alastairs-place.net> 
> wrote:
> 
> On 10 Sep 2018, at 13:21, iain <i...@falsevictories.com 
> <mailto:i...@falsevictories.com>> 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?
> 
> In your -becomeFirstResponder, you could examine the current event (noting 
> that keypresses aren’t the only way you could gain keyboard focus) to 
> determine whether it was a Tab or Shift-Tab keypress. You can get the event 
> using [NSApp currentEvent]. Make sure it works with Full Keyboard Access 
> turned on in System Preferences as well.
> 

Ah, good idea, thank you.

> Also note that you will want to implement the relevant accessibility support; 
> otherwise, when users turn on VoiceOver, they won’t be able to focus 
> individual elements in your view, and the VoiceOver cursor (which is not the 
> same thing as the normal keyboard focus system) won’t interact properly with 
> your view.
> 

Yup, that’s all working already, the proper keyboard focus handling was the 
last bit I needed that I couldn’t work out.

thanks

> Kind regards,
> 
> Alastair.
> 
> --
> http://alastairs-place.net <http://alastairs-place.net/>

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to