Setting combobox.text issue in 2023r3

There seems to be a problem with this as of latest release (on macos anyway). I have a self.colorSequenceComboBox which is populated by a bunch of AddRow calls in its opening event, then me.SelectedRowIndex = 2 sets the item I want displayed initially.

Problem is this: when I later reset its text:
self.colorSequenceComboBox.text = newText

newText gets clobbered and instead the combobox’s 1st row is always inserted into its .text property as reported by:
dim debug_colorSequenceComboBox_Text as string = self.colorSequenceComboBox.Text
added right after.

The only way around this is to always:
self.colorSequenceComboBox.SelectedRowIndex = -1

right before setting its text property. This did not happen before 23r2 and now forces me to sift through all my projects where I programmatically set the combobox.text property and want it to stick.

Are you going to file an Issue with a sample project?


Tried to reproduce but I get a different result, what I did:

  • combobox with 0 to 20 number on each row
  • selectedrowindex = 2 (so Text = 2)
  • combobox1.text = “newtext”
  • dim checktext as string = combobox1.text //I get 2 here

some screenshots:
image

image

image

I guess I’m doing something different, that’s why is important to create an Issue with a sample project.

I verified this one and created an issue already for it (https://tracker.xojo.com/xojoinc/xojo/-/issues/74556)

Looks like the workaround until it gets fixed is to set the SelectedRowIndex to -1 before setting the new text via code.

It is not reproducible when the text is typed directly in the Combobox control itself.

Sorry for the inconvenience, guys. :pray:

I hate to say it, but probably not. Not meaning to be negative but I’ve been filing reports on a persistent “DebuggerHook” crash for years, went to the trouble of stripping my project and submitting what I could, with no traction.
After recurrent crashes I filed a followup crashlog, and was asked to once again strip down a project and submit, which I declined to do. I simply don’t have time to waste on issues that don’t get attention. I’m hoping that Xojo will peruse the forum and scrape what they want and fix what they intend. Diminishing returns and all that.

this persists in 2023r3.1. I thought one of the 3 reported bug fixes dealt with this.

Hello,
The text field of the combo box is just a text field
must be added to the combobox list before it can be displayed.
With selection -1 you have overridden the display and see your text.
My programming for example:
Insertion position here 0 can also be any other position.

ComboBox1.AddRowAt(0,“Hello”)
ComboBox1.SelectedRowIndex = 0

label1.text = ComboBox1.text

well if it’s just a text field why does its contents get clobbered after a write new text to it with ComboBox1.text = “newText”? unless I first reset selectedRowIndex to -1.

This worked as expected pre-23r3 and r3.1 did not fix it.

The problem arises when you pre-populate the combobox with a bunch of AddRows, set the selectedRowIndex to what you want, but then come back and copy some arbitrary text into the box that may not even be part of its pre-populated list (the whole point of a combobox: a combo of preset and arbitrary strings). Your new text gets clobbered by some new event that is probably triggered after your ComboBox1.text = “newText” call that then resets the text to match the existing selectedRowIndex, not what you wanted.

hello Peter,
I can’t fully understand your problem
my test program to view

https://www.dropbox.com/scl/fi/9ca1o86oxfviwvc1g2csi/Test-combobox.xojo_binary_project?rlkey=h25obstcfb26cem0gg5ccmyjb&dl=1

…and this is why “changed” events should not fire when the control’s contents are changed in code…

Disagree.

It works for others, should work for Xojo.

I also would like to see a sample explaining it.

please see my original post.

Not sure what else to tell you, here is an excerpt from my method that causes the issue (screenshot of a live run):

It sets the combobox text to a string value read from a dict. Clearly this code should never break yet you can see it did: the combo box text is not what was read from the dict (it is always defaulted to 1st row of the combobox that was pre-populated at Open). If I precede this block with a SelectedRowIndex = -1 it runs as expected and never breaks. This behavior only began with 2023r3 and now r3.1.

This isn’t a fully functional sample, this is a snippet.

We meant something we can download (as you need components, events, etc) and run on our side seeing exactly what you see.

If I read Javier Menendez’ post correctly from 18d ago, seems that he reproduced the problem and acknowledged that it was recently introduced: (https://tracker.xojo.com/xojoinc/xojo/-/issues/74556 )

Well… what he acknowledged was fixed.

OK, thx Rick.