Segmentedbuttons truncated

Feedback Case Number:
Capture d’écran 1
Capture d’écran 2

The right edge isn’t drawn. Annoying…

On MacOS.

Do you have a sample project? You can zip it and upload to the forum post.
What version of macOS?
What version of Xojo?
What Mac Button Style?
What Selection Style?

I can’t reproduce with Xojo2024r3 and macOS 13.7

There is a bug report DesktopSegmentedButton Changes Width at Runtime #74795

I do MySegmentedButton.width = MySegmentedButton.width + 6 in the open event of my window to workarround this problem.

I’m not seeing a problem, but my buttons have space. 2024r3, macOS Sequoia 15.0.1 (24A348)

1 Like

Big Sur (11.7.10)
2024 release 3
All styles
All selection styles

Capture d’écran 1
Capture d’écran 2

I’ll try this one. But the problem remains at design time.

Xnip2024-10-09_10-21-37

Tried your solution. The first with your code in the opening event of the button, the last, in the window opening event.

The right edges are always truncated.

This appears like that in two of my application. One segementedbutton contains picture and the other text.



The one containing the text is creating at run time (the user can change the count of button and the text inside), here is my code:

Dim iNbre, Fin_iNbre as Int16
Dim TpSegTypes(-1) as String
Dim TampSeg as Segment

TpSegTypes = TampText.Split(CarTab) ' Pour les segments sélectionnés
#If DebugBuild Then ' Un Split("") retrourne un tableau vide
  If (TampText = "") and (not(TpSegTypes.LastIndex = -1)) Then MessageBox "Problème Tom :" + EndOfLine + "TampText = '" + TampText + "'" + EndOfLine + "TpSegTypes.LastIndex = " + str(TpSegTypes.LastIndex) ' Fin
#EndIf
Fin_iNbre = App.DiffTypes.LastIndex ' Forcément > -1 et < 5
While SegButtChType.LastSegmentIndex > Fin_iNbre
  ' Break
  SegButtChType.RemoveSegmentAt SegButtChType.LastSegmentIndex ' On enlève le dernier mais on pourrait enlever n'importe lequel
Wend
While SegButtChType.LastSegmentIndex < Fin_iNbre
  ' Break
  TampSeg = New Segment
  TampSeg.Caption = str(SegButtChType.LastSegmentIndex) + "Ab" ' N'importe quoi on s'en fou
  SegButtChType.AddSegment TampSeg
Wend
If not(Fin_iNbre = SegButtChType.LastSegmentIndex) Then MessageBox "Error ! Please contact the authors, FaireSegButtChType" + EndOfLine + str(Fin_iNbre) + " ≠ " + str(SegButtChType.LastSegmentIndex)
For iNbre = 0 to Fin_iNbre ' = SegButtChType.LastSegmentIndex
  TampSeg = SegButtChType.SegmentAt(iNbre)
  ' MessageBox str(iNbre) + " / " + str(Fin_iNbre) + EndOfLine + TampSeg.Title
  TampText = App.DiffTypes(iNbre)
  TampSeg.Selected = not(TpSegTypes.IndexOf(TampText) = -1)
  TampSeg.Caption = TampText
  TampSeg.Width = (SegButtChType.Width / (Fin_iNbre + 1)) - 2
Next iNbre

TampText as String is a tabulated string containing the text I pass to my Method to select one or some of the buttons. (if I want to have Bbb and Eee selected I send “Bbb tab Eee”). App.DiffTypes is a array of string containing each segment.

For the other application with the picture, I do in the open Event:

SegButtSymb.SegmentAt(0).Icon = EchellePict(PionCoul_A)
SegButtSymb.SegmentAt(1).Icon = EchellePict(PionCoul_B)
SegButtSymb.SegmentAt(2).Icon = EchellePict(PionCoul_C)
SegButtSymb.SegmentAt(3).Icon = EchellePict(PionCoul_D)
SegButtSymb.SegmentAt(4).Icon = EchellePict(PionCoul_E)
SegButtSymb.SegmentAt(5).Icon = EchellePict(PionCoul_F)
SegButtSymb.SegmentAt(6).Icon = EchellePict(PionCoul_G)
SegButtSymb.SegmentAt(7).Icon = EchellePict(PionCoul_H)
SegButtSymb.SegmentAt(8).Icon = EchellePict(PionCoul_I)
SegButtSymb.SegmentAt(9).Icon = EchellePict(PionCoul_J)
SegButtSymb.SegmentAt(10).Icon = EchellePict(PionCoul_K)
SegButtSymb.SegmentAt(11).Icon = EchellePict(PionCoul_L)

#If TargetWindows Then
  For iNbre = 0 to 12
    SegButtLettr.SegmentAt(iNbre).Width = 23
    SegButtSymb.SegmentAt(iNbre).Width = 23
  Next iNbre
#EndIf
SegButtLettr.Width = SegButtLettr.Width + 6 ' @w@a@ #74795 DesktopSegmentedButton
SegButtSymb.Width = SegButtSymb.Width + 6 ' @w@a@ #74795 DesktopSegmentedButton
' MessageBox str(SegButtLettr.Width) + " , " + str(SegButtSymb.Width)

I made many tests to workarround this problem. The result for the one with picture:

I’m now under Sonoma but it work on my previous system Mojave.

It’s far away my knowledge… I’ll try to take the best of it for me.

You have to play with the width of the segmented button (the one containing all the segment):
MySegmentedButton.width = MySegmentedButton.width + 6
I add 6 because I see it works.
and the width of each segment:
MySegmentedButton.SegmentAt(iNbre).Width = xx

Try to code something like:

MySegmentedButton.width = MySegmentedButton.width + X ' Find the good number, but I bet 6 as for me (depending of what you enter in the loop below)
For iNbre = 0 to MySegButt.LastSegmentIndex
  MySegButt.SegmentAt(iNbre) = XX ' Find the good number
Next iNbre

Olivier, you’re French no? Just curiosity :wink: .

Oui, à la question…
Yes… the solution works fine !