0

It seems that the NSDatePicker nextKeyView is never taken into account.

I can key tab to the NSDatePicker, but never get out of it though nextKeyView is correctly set.

When inside the picker, if I press the tab key, the focus goes correctly from day to month to year text fields, but is sticked in year text field and does never go to the nextKeyView control.

Same thing in the reverse direction, shift-tab goes correctly from year to month to day but is sticked there inside the NSDatePicker.

I guess this is a bug of NSDatePicker.

How can I subclass (or any other type of solution) to overcome this problem ?

enter image description here Also, a log of the next key view chain, just to prove they are set

Initial first responder <NSTextField: 0x100587c60>
next key view <NSDatePicker: 0x6000035008f0>
next key view <NSComboBox: 0x100636740>
next key view <NSTextField: 0x10063e5a0>
next key view <NSTextField: 0x100587c60>
AirXygène
  • 2,409
  • 15
  • 34
  • 1
    Works out of the box https://imgur.com/a/6DNo5eH – Marek H Mar 07 '19 at 11:51
  • Well, obviously not in my case. I checked the nextKeyView were correctly set. So I guess the question would be What could prevent them from working ? I added a capture of the screen. – AirXygène Mar 07 '19 at 12:00
  • How can we reproduce the issue in a small test project? – Willeke Mar 07 '19 at 12:55
  • I’ll try to make the smallest possible extract and provide it. If it matters, the view is in a sheet triggered by a segue of a storyboard. – AirXygène Mar 07 '19 at 13:08
  • I see tableview - don't you have your nsdatepicker in your tableviewcell? I faced some issues in 10.12 but same setup worked on 10.14 – Marek H Mar 07 '19 at 14:44
  • The date picker is outside the table, so not in a cell. However, your remark lit a spark of understanding in my mind. The controller that manages this view (the view contains the table view and the other controls) has a keyDown: method. Might be something to dig there... – AirXygène Mar 07 '19 at 17:44

1 Answers1

0

Here is the catch : The controller that manages the view has a keyDown: method, because it needs to react on a "delete" key down. This method was not calling [super keyDown:event] if the pressed key was not "delete" (such as the "tab" key).

Adding the call to super when the key is not to be handled by the controller solved the problem.

Why was a tab key pressed handled correctly in some cases (e.g. when focus is on a text field) and not other cases (e.g. date picker) remains unexplained.

Thanks to all the persons that posted comments and help me figure this out.

AirXygène
  • 2,409
  • 15
  • 34