Set of CheckBoxes / Action

XOJO 2019r3.2 / Windows Desktop

My problem ,
I have a set of CheckBoxes that can individually be changed by the user.
Everytime a CheckBox changes a ListBox will be updated.
That works fine.
But,
I have 3 buttons -> ‘Select All’, ‘Select None’ and ‘Invert Selection’ for changing the same set of CheckBoxes.
What happens : when I select ‘All’ ‘None’ or ‘Invert’ the CheckBox Set action will be launched for all the changed CheckBoxes. The ListBox will be updated multiple times, and that should be only once after clicking 'All, ‘None’ or ‘Invert’.

I’m looking for a solution for this problem.
It is perhaps easy, but I cannot find a correct solution.

Thanks
Regards
Etienne

Do not perform your ListBox actions in the CheckBox Events.

Quick & Dirty:

  • Create a single Method which performs the actions you did before in those CheckBox Events.
  • Start this Method using Xojo.CoreTimer.CallLater.
  • Do a CancelCall before those CallLater calls.

CheckBox Event Example:
Xojo.Core.Timer.CancelCall(AddressOf DoListBoxStuff)
Xojo.Core.Timer.CallLater(50, AddressOf DoListBoxStuff)

This way, the ListBox actions would be performed with a delay when a CheckBox Value changes. The CancelCall before the CallLater would stop the execution and so only the last Call should be performed.

1 Like

Another approach:

  • Put your ListBox Actions in the CheckBox Event into a
    If Me.Enabled Then

    EndIf

  • Disable the CheckBoxes before your Button Event changes the CheckBox State, re-enabling it afterwards.

Ok I quickly tested the second solution with the ‘If Me.Enabled Then’ and that seems to work for me.
Further tests will be done to be sure if everything works fine that way.
Thank you very much Sascha S.

Regards
Etienne

1 Like

Glad i could help a bit. :slight_smile:

Or you could Subclass the CheckBox and implement a silent toggle so the Action event isn’t triggered.

@JulianS
The link you provided is not working for me.
Regards

Doh, odd, try this:

@JulianS
Ok I could download the project code.
That’s a very nice solution too for my problem. It works very well.
Thanks
Regards
Etienne