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.
How do you prevent a CheckBox or ToggleButtonBase from changing?
116 Views Asked by 1.21 gigawatts At
2
There are 2 best solutions below
0
On
I've added an event listener for a mouse click event and this seems to work but there is a flicker where you can see it was selected for an instant.
IEventDispatcher(checkbox).addEventListener(MouseEvent.CLICK, function(e:Event):void {
trace("click");
ToggleButtonBase(target).selected = !ToggleButtonBase(target).selected;
e.stopImmediatePropagation();
e.preventDefault();
});
Using this, if I trace the events, it's:
- change
- change
- click
Not ideal but it seems to be working.
You can just disable any mouse events for this checkbox and would still be able to change the selection programmatically with selected=true: