Enable/Disable events

I have a fair amount of experience with VBA/Excel and with that, you can enable and disable events as needed, is that possible in Xojo? in particular, I’m trying to control what is entered into a ComboBox based on the list, when a user begins to type, the TextChanged event fires and looks to verify that it is in the list and populates if it is, this causes another occurrence of the TextChanged event and I end up with a stackoverflow.

To fix this you can add a boolean property to the window called justChanged. Then in the text changed event test justChanged. If it is true, set it to false and do nothing. If it is false then set it to true and proceed with the code that would change the text property (and therefore cause the stackoverflow). Make sure that justChanged is set before the code that changes the text property is executed or the problem will not be cleared up.

  • Create a window string property called HasChanged
  • In the TextChanged place the following text :

If strComp(Me.Text,HasChanged,0)<>0 then //Do your code end if HasChanged = me.Text

This way the code executes only if the text entered is different than what was displayed.

Thanks for the help guys. after I posted this last night I did the following and it’s basically the same path you are leading me down with your responses. This ComboBox is for entering the State as part of an address, I wanted to be sure it was uppercase and if they entered something other than a State abbreviation it would clear the fields, both issues are addressed with this code.

Dim i as Integer
Dim ilist as String
If Len(Me.Text)=2 then
for i = 0 to Me.ListCount-1
If Me.Text=SelState then
Exit Sub
End If
If Me.text<>ilist then
End If
End If

Sorry, I forgot to mention that ‘SelState’ is the string property I used to accomplish it.