I have a window that pops up with 4 combo boxes, populated and set to ListIndex = so they display the first item.
When the ‘Done’ button is pressed, this code runs and sets properties inside Module1 (not inside the window):
//SET PROPERTIES BASED ON INDEX POSITION OF COMBO BOXES
TabColumnOne = ComboBox1.ListIndex
TabColumnTwo = ComboBox2.ListIndex
TabColumnThree = ComboBox3.ListIndex
TabColumnFour = ComboBox4.ListIndex
//VALUES BEFORE WINDOW CLOSED
System.DebugLog("TabColumnOne = " + TabColumnOne.ToText)
System.DebugLog("TabColumnTwo = " + TabColumnTwo.ToText)
System.DebugLog("TabColumnThree = " + TabColumnThree.ToText)
System.DebugLog("TabColumnFour = " + TabColumnFour.ToText)
//CLOSE THE WINDOW
WindowmatchColumns.Close
//VALUES AFTER WINDOW CLOSED
System.DebugLog("-------------------")
System.DebugLog("TabColumnOne = " + TabColumnOne.ToText)
System.DebugLog("TabColumnTwo = " + TabColumnTwo.ToText)
System.DebugLog("TabColumnThree = " + TabColumnThree.ToText)
System.DebugLog("TabColumnFour = " + TabColumnFour.ToText)
If I do nothing before pressing the button, the integer property “TabColumnOne” now has a value of -2147483648
If I complete all combo boxes with something other than the first entry, the integer property “TabColumnFour” now has a value of -2147483648
This seems odd. Please can anyone shed any light on this?
In general when you have a property that is changing when it shouldn’t do the following: make the property a computed one. Now you have a getter and a setter. For the setter add a break or some logging.
Something is odd with the change event of the combobox. It fires way too often. When you close the window the index of the combobox is changing, too, and resetting your module values.
When you close the window the controls are also closed & disposed of
Trying to read their values AFTER calling close will give you issues
I’m more surprised you do not get nil object exceptions with this code
Interesting. If you break it in PushButton1.Action and debugview the vars are they also out of whack or is it the .ToText that’s causing the issue? Try str(TabColumnOne) instead just out of interest.
You get an extra “Change” event on macOS when you close the window
So the code you have in the combobo xhange event handlers runs and causes the effect youre seeing
Put a boolean on the window “isclosing” and in your button set that to true and then your chnage events can see if that is set and do nothing
[quote=434090:@Norman Palardy]You get an extra “Change” event on macOS when you close the window
So the code you have in the combobo xhange event handlers runs and causes the effect youre seeing
Put a boolean on the window “isclosing” and in your button set that to true and then your chnage events can see if that is set and do nothing[/quote]
Sorry for the confusion. It arose because I totally forgot about the code existing in the change event - because I was setting all the properties with the Ok button these change events were redundant. It was the OS X behaviour you pointed out in the first place that triggers change events on window close that was my missing link.