Hi
>One example is the Maps app that is delivered by Apple. Theoretically, the field to enter a location could have the focus after starting the app (it is the only field that can receive a focus)
but it >has not. And this is the case for a lot of apps or situations. I think that you should not be distracted by the focus from the main thing, namely the map.
I wouldn’t take apps that are ported back from the iOS world (where keyboard focus has a different priority) using Catalyst as reference (in macOS 11 Big Sur this started for maps, imessage etc.). They have IMHO a sub-par experience to ‘true’ desktop apps. Apple Maps used to focus on the search field. Now its keyboard focus is on the map itself… the arrow keys can be used there, if you set the focus on the search field then you can tab to the results list and then keyboard focus runs havoc because it’s reacting to the item selected by default and popping up floating windows which get the focus or suddenly the map itself gets the focus again and so sooner or later it’s not possible anymore to move through the results list via arrow keys …
Using the same app on pre-Big-Sur systems the keyboard focus performs predictably and remains stable
Best,
Stefan
--
You received this message because you are subscribed to the Google Groups "wx-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wx-dev+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-dev/GV0P278MB02433B2DEEFB04B82E64B174DD39A%40GV0P278MB0243.CHEP278.PROD.OUTLOOK.COM.
Hi Hardy
Anyway, fact is that in macOS there is a way to disable the focus.
Yes, at least to set it to the toplevel window itself
- but not with resignFirstResponder which is a callback method, the OS notifies a control that it intends to give the keyboard focus to another control, you can veto it be returning false.
https://developer.apple.com/documentation/appkit/nsresponder/1532115-resignfirstresponder/ The docs explicitly say “Never invoke this method directly”
- I think the way to implement this would be to call makeFirstResponder on the toplevel NSWindow with an NSResponder of nil, resetting it to the NSWindow itself.
Right now when a SetFocus event is sent to a control that cannot really be focused (canBecomeKeyView returning false) I check whether the window is not yet visible, if this is the case I’m preparing the NSWindow with setInitialFirstResponder, otherwise I return false and let the focus be where it was. This could of course be changed to setting the focus to the NSWindow itself, but I’m reluctant to do this, because of the platform differences about which controls can be focused at all, and this change would perhaps lead to more surprises for users on macOS when the app itself is not aware of these differences.
So an explicit implementation would be better IMHO, which could set the focus to the toplevel window itself, if this works the same across the platforms then this could be the place to hook makeFirstResponder: nil into …
Best,
Stefan