Segmented button issue

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.

after clicking

Looks like a bug with the focus ring
screencast2024-07-154PM-54-51-ezgif.com-video-to-gif-converter

This is what I’m getting here… maybe you can attach an example project to the issue? https://tracker.xojo.com/xojoinc/xojo/-/issues/76919

Also: what macOS version? What Xojo release are you using? (please add that info to the opened issue)

Thank you!

Segmented

As sometimes it does not occur, also add Xojo version and macOS version where the issue manifests.

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.

Done


Steps to reproduce:

  • add a segmented button
  • change Selection Type to multiple
  • add a listbox
  • run

macOS 13.6.7, 14.5, Xojo 2024r2

Another Gif, see how just the first time the focus ring jumps to the segmented button but when we click the listbox then it doesn’t happen anymore:

76919


Edit:

Yes, the problem is that the focus ring jumps once to a non clicked segment.

1 Like

Looks like Alberto did my work for me when I was distracted! But yes, it was a multiple select button. Latest Xojo, MacOS 14.5, MacBook Pro M3.

2 Likes

We spoke about this problem in DesktopSegmentedButton and focus ring , and a report has been made https://tracker.xojo.com/xojoinc/xojo/-/issues/69024

(I post a comment with my modified workarround).

1 Like

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.

Thank you for letting me know @AlbertoD, I have added a comment to the issue.

I’ll put together an example project to demonstrate the Radio button tabbing behaviour and submit a new issue.

Edited to add: Issue #76924

1 Like

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)

2 Likes

Segmented button should have a focus ring, when Full Keyboard Access is turned on:

  • Tabbing into a segmented button should put the focus ring on the currently selected segment (not the first).
  • Left and right arrows should move the focus with space bar selecting it.

You can see the stock behaviour in pretty much any print dialog box:

  • Open the Layout page
  • Set the Pages per sheet value to more than 1
  • The Z order segmented button will activate and show the correct behaviours.

This is single selection, right? Have you seen a multi-selection option?

Pages has a multi-select segmented button and it works much the same.

  • Tabbing into a segmented button should put the focus ring on the first selected segment button.
  • Left and right arrows should move the focus with space bar selecting/deselecting the highlighted segment.

You can see this in Pages:

  • Create a document and highlight a word
  • Open the Format side panel
  • Select the Style tab
  • There is a muti-select segmented button for B (Bold), I (Italic), U (Underline), S (Strikethrough).

The only time the first segment is selected is if there are no segments currently selected.

Not here:
screencast2024-07-161PM-25-02-ezgif.com-video-to-gif-converter

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.

Agreed. I’ve just checked and you’re correct. macOS 14.5.

1 Like

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.

This should deserve a report at Apple.

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.

I hope is clear.

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.