Xojo Version 1.2 2024 Windows. This is kind of an armature question on the Checkbox Control. For trapping - I need to change the Checkbox value to false (unchecked) without triggering the code in the Checkbox Change Event. Both code examples below still trigger the Change Event code which I don’t want (Setting Off a Bug In My Program), I just want to change it’s state. Is it possible or is there a work around?
Checkbox1.Value = False
' Or
Checkbox1.VisualState = Checkbox.VisualStates.Unchecked
Thank You
Jeff
An alternative if you don’t want to add additional properties is to use the Enabled state of the checkbox. Same concept, just using a built in property.
This issue/need comes up very very frequently. Xojo should add “User Action” and “Programmatic Action” as separate events to all controls. The existing Action event would then be “Any Action”.
I don’t think that’s necessary. When you need to know the source, there are multiple ways to flag to yourself that you can ignore the change.
I like to rely on the fact that the event occurs whenever it is the Value has Changed. That way I can do certain actions every time. Things like enable or disable other UI members based on the value state of a Checkbox. With this design, I’m not concerned with who or why the state is changing. I just rely on the behavior to be sure the other controls are enabled or disabled correctly.
Things that rely on knowing the change was not caused by code I can flag myself.
That’s not to dismiss your idea, I’m sure it is useful to you. It is just something I have not struggled with myself.
Very true. But those ways do add overhead to the work you’re doing.
As an aside, I have noticed that many of the MBS controls (e.g., DesktopNSSwitchControlMBS) do not trigger the Action or a change event when the control’s value has programmatically been changed. Very handy, that
I would take @Julia_Truchsess 's suggestion and make it a parameter in the ValueChanged event called “ViaUIInteraction” or similar. This keeps compatibility with existing code while adding valuable context for those who need it.