Sizing issue with SegmentedControl

When an application is compiled for Windows on Mac OSX, the segmented controls don’t get sized the same as when the exact same application is compiled on Windows. Is anyone else seeing this?

The rear application was compiled on Mac OS X, the front one was compiled in Win 7:

So I made a feedback case:

<https://xojo.com/issue/33127>

Nothing new there, just going through the channels…

[quote=79098:@William Koperwhats]So I made a feedback case:

<https://xojo.com/issue/33127>

Nothing new there, just going through the channels…[/quote]

I think I have a feedback case that’s related to this issue. <https://xojo.com/issue/31338>

I thought it was just the IDE, but it also affects compiled apps? That majorly sucks.

if I may ask, are those custom controls, or did you purchase them somewhere? (The custom toolbar and the Xojo like docked-panel)

[quote=79129:@Shane Gibbs]I think I have a feedback case that’s related to this issue. <https://xojo.com/issue/31338>

I thought it was just the IDE, but it also affects compiled apps? That majorly sucks.

if I may ask, are those custom controls, or did you purchase them somewhere? (The custom toolbar and the Xojo like docked-panel)[/quote]
Yes it effects compiled Win apps as I removed the segmented control from my xplat app because of this issue.

I think that the two issues are certainly related, but ever since the IDE went Cocoa, for the most part I’ve found that controls get drawn correctly in the window editor.

I can get this to look correct in the compiled app on both platforms, but I need to compile it on whatever OS it will be deployed in. It’s not particularly difficult since I run Windows under Parallels on Mac OS X and share a “Dev” directory, but it’s definitely a bug.

[quote=79129:@Shane Gibbs]
if I may ask, are those custom controls, or did you purchase them somewhere? (The custom toolbar and the Xojo like docked-panel)[/quote]

They’re all custom drawn by me, nothing off the shelf unfortunately. I don’t want to hijack this thread, but if you PM me I can give you some direction on how I did it all…

Thanks. I’ll PM you later when I start working on an app that actually needs something like that. I like seeing how things work in the software world.

Do you explicitly set each segment’s width?

Nope, I just set the width of the control in the IDE. I let the framework handle the segment sizing. It’s definitely a compiler issue since it builds to different sizes depending on which OS compiled it. I haven’t looked to see if the Mac build is different when compiled on Mac OS vs. Windows.

I found this to be the most reliable way of using segmentedControls, on open, you get each element and explicitly set it’s width.

Sam, does this work reliably cross-platform?

I don’t know, been a while since I’ve done anything with a Windows machine.

And make sure you call SizeToFit

I believe the segmentedcontrol has a few bugs. Try creating one dynamically (never appears). Did you use

SegmentedControl1.SizeToFit

To ensure proper resize? I have a custom segmented control floating around here that goes vertical or horizontal ( and themes… Both user defined) because I kept running into issues with the segmentedcontrol (can repost if needed).

Hmmm …. works here if you create one as the base for a control set then add another
Remember to add items to the new one
I have one on a desktop window at 20,20 that is named, inventively segmentedcontrol1 and it has index 0 in the control set

[code]
dim s as segmentedControl
s = new SegmentedControl1

dim seg as SegmentedControlItem
seg = new SegmentedControlItem
seg.Title = “hello”
s.Items.Append seg
seg = new SegmentedControlItem
seg.Title = “world”
s.Items.Append seg

s.top = 100
s.left = 50
s.SizeToFit[/code]

Just to reiterate, the original issue was that the Windows build containing a segmented control was a different size when compiled on Mac OS X vs compiled on Windows using the exact same source code.

The bug in the (Xojo: Account Login)>]feedback case that I opened has actually has been verified, but I’m just a little concerned that other controls may have a similar problem.

I know that segmented controls have has other sizing issues in the past but, other than this, I’ve been pleasantly surprised at their predictability.

[quote=80696:@Norman Palardy]Hmmm …. works here if you create one as the base for a control set then add anotinitial her
Remember to add items to the new one
I have one on a desktop window at 20,20 that is named, inventively segmentedcontrol1 and it has index 0 in the control set

[code]
dim s as segmentedControl
s = new SegmentedControl1

dim seg as SegmentedControlItem
seg = new SegmentedControlItem
seg.Title = “hello”
s.Items.Append seg
seg = new SegmentedControlItem
seg.Title = “world”
s.Items.Append seg

s.top = 100
s.left = 50
s.SizeToFit[/code][/quote]

Sheesh and after posting about sizetofit reviewed the dynamic code, missing both sizetofit and seg.Visible = true. The base membersets are invisible in my case. Thanks Norman! :slight_smile:

Ok, here it is, 2 years later, and resizing SegmentedControl is again (still?) an issue.

I have a SegmentedControl in my app, created in the IDE, having two segments. It has a width of 412. In my code, I’m adding a new segment and want the control to show all three segments in the same space. Here’s my code:

[code] Dim i, j As Integer
Dim s As new SegmentedControlItem

j = SegmentedControl1.Width
s.Title = “Third”
SegmentedControl1.Items.Append(s)

For i = SegmentedControl1.Items.UBound DownTo 0
SegmentedControlItem(SegmentedControl1.Items( i )).Width = j / (SegmentedControl1.Items.UBound+1)
Next

SegmentedControl1.SizeToFit
SegmentedControl1.Refresh
[/code]
Checking ‘J’ at the start, the size of the control is, as expected, 412. After the SizeToFit call the control’s width expands to 423. Further debugging shows that the widths of the individual segments is believed to be 137 each, as they should be, even though they are actually drawn larger, a full 1/3 of the larger control.

So, why should the SizeToFit cause the control to get wider when the separate segments have widths specified to fit within the boundaries of the control. Is this a bug or am I missing something?

BTW, this is on a Windows 10 system using Xojo 2016r1.1

Dale

Dale, yes this is still an issue. Norman mentioned in (Xojo: Account Login)]this feedback case that the Windows version of this control was completely non-native. I suspect that this won’t get fixed until after the push to move away from the old Windows UI frameworks.

William, that is what I concluded also. Since the spot on the UI was of limited size I had to come up with a different solution. So I went ahead and implemented it using a Canvas.