apache-flexflex4flex-spark

How do you prevent a CheckBox or ToggleButtonBase from changing?


I have a Spark CheckBox and I'm trying to prevent it from changing when clicked. In most Flex components there is a CHANGING event and you can prevent default. I've only found a CHANGE event and if I listen for that event and then set checkbox.selected = !checkbox.selected; it just dispatches changed again and the check box is reselected.


Solution

  • You can just disable any mouse events for this checkbox and would still be able to change the selection programmatically with selected=true:

    <s:CheckBox id="myCheckbox"
                mouseChildren="false"
                mouseEnabled="false"/>