How to Avoid When CheckBox Changed Event Cascades

This code sample is to demonstrate how to use event times to distinguish between manually triggered Checkbox change events and events triggered by software.

The basic idea is to use the time interval from the last Checkbox Changed event to judge if it was done manually versus procedurally. A limit of 30 milliseconds is used as the boundary, with shorter intervals interpreted as programmed, and longer intervals as manual.

This sample app lets you switch between the two approaches, for test purposes.

It simulates a radio button, which is a group of checkboxes that allow at most one item of the group to be ON at a time.

The debounce switch toggles between the two modes. I call it that because this problem mirrors the problem circuit designers have of restricting the effects of metal contacts rapidly bouncing off each other when making and breaking contact and emitting spurious ON/OFF signals.

Designer:

Source:
checkbox_radio_button_debounced.aia (3.2 KB)

Blocks:

Sample run:
sample run

Note how erratic the checkbox action is in the non-debounced setup.