I’m using a DesktopSegmentedButton, nothing unusual about it. When the app launches, it looks normal. When any button is clicked, the left hand segment gets a blue border around it. Doesn’t matter what is clicked or unclicked after that. This doesn’t seem normal? It looks like a focus highlight (similar to a textbox with focus) but it is only around the first segment. If the tab is redrawn, it goes away and never comes back, so this happens only on the initial view.
I bet you have “full keyboard access” enabled. When that happens, the focus run will move from segment to segment by keystrokes. In this case I think it has to be the left and right keys.
I use “full keyboard access” all the time on macOS (currently 14.5) and I was thinking this was expected behaviour, but maybe I’m wrong.
You’ll notice a similar behaviour when you tab into a group of Radio buttons. If there are three radio buttons (with only # 3 selected), but #1 gets the focus ring. Then use tab (and shift-tab) to navigate to each radio option, then use the space-bar to simulate a click to activate the option.
Same with the segmented control, except you use arrow-keys to navigate to each option, then space-bar to activate the highlighted option.
But now that I look at this more closely, and compare this Xojo control behaviour against the same kind of controls used in macOS System Settings or BBEdit Settings, I notice the following:
“Standard” macOS tabbing behaviour:
Tabbing into a segmented control, the focus ring goes to the active button. Then arrow-keys to navigate and space-bar to activate.
Tabbing into a radio button group, the focus right goes to the active radio button. Then arrow-keys to navigate and space-bar to activate.
“Xojo” macOS tabbing behaviour:
Tabbing into a segmented control, the focus ring goes to the first segment button regardless if it is active (but not always). Arrow-keys and space-bar work as expected.
Tabbing into a radio button group, the focus ring goes to the first radio button regardless if it is active (always). Tab (and shift-tab) for navigation. Space-bar works as expected.
The underlined text above highlights where the Xojo controls differs from standard macOS tabbing behaviour.
We may need to contact @Javier_Menendez as the ‘fix’ involves removing the focus ring and not match what other apps do on macOS:
[Javier Menendez]
Ok, removed the focus ring from this control on macOS because it didn’t make much sense at all. The control is not able to move among existing segments using the Tab key, while even can’t fire the FocusReceived / FocusLost events.
As far I did see, what I did is the standard behavior even on a Xcode created app. When universal Access is enabled (full keyboard), then you can use arrow keys / tab to navigate the segments, plus the space bar to “select”/“unselect” the segment(s)
Edit: oh, it changes the behavior if the selected segment was clicked or selected with keyboard (above is click then tab). If we tab to it and select a segment with the keyboard then the tab works as described by Ian.
This seems dumb, as 2 different teams implementing behaviors and making their own choices. I hope that the “last selected segment” by any means is the landing place of a tab.
After more tests it looks like the behavior is like this:
the tab shows the focus ring to the last segment that had the focus ring
so, if you start Pages, click something then Tab, because there was never a focus ring on a segment, then the first segment gets the focus.
If you tab, select a segment and tab again, then when you tab back the selected segment has the focus ring.
If you tab, select a segment and move to another segment, the focus ring is changed to this other segment, if you tab out and back, that last segment with the focus ring is the one that shows the focus ring.
Haven’t checked Apple, but in Xojo the tabbing and space bar selection only works if there is a focus ring. Once that is lost (by clicking elsewhere) then clicking anywhere in the segmented button control does not bring it back, and tabbing/space bar no longer works. Regardless of what Apple does, it really should work the same each time you use the control.