In my GUI, I have a TGComboBox with two possible values:
Later, I want to change the selected value within the script, using the function Select.
This works fine if the TGComboBox is not editable. However, if I define the constructor editable, then the function Select does not update in the GUI the top value shown. It still shows the predefined value in the constructor.
box = new TGComboBox(frame,"predefinedvalue")
box->AddEntry("predefinedvalue",0);
box->AddEntry("newvalue",1);
box->Select(1);
When I click on the box, the “newvalue” is highlighted in the list, but is not show in the top position (is not visible when unclicking). Is this an expected behaviour? How do I manage to move it to the top, as when I click it normally from the GUI instead of command line?
fSamplesPerPulseBox = new TGComboBox(fFileFrame, "4096");
fSamplesPerPulseBox->AddEntry("4096",0);
fSamplesPerPulseBox->AddEntry("8192",1);
fSamplesPerPulseBox->Select(1);
See attachment 1.png and 2.png for the result I mention (SP value). The 1st value is selected (highlighed when I display the whole list), but the top visible value is not update.
If I define instead as non-editable, by eliminating the second argument of the constructor:
fSamplesPerPulseBox = new TGComboBox(fFileFrame);
fSamplesPerPulseBox->AddEntry("4096",0);
fSamplesPerPulseBox->AddEntry("8192",1);
fSamplesPerPulseBox->Select(1);
then I get attachment 3.png directly, the correct value is shown on top from the beginning and everything is fine.