P Varga
P Varga

Reputation: 20249

how to distinguish between value set by user interaction vs binding on a Spark input component

How do I determine whether a value set comes from user interaction with the input component, or from binding?

Example:

<s:NumericStepper xmlns=...
                  value="{SomeDataManager.foo}">
<fx:Script>
    override public function set value(newValue:Number):void {
        if (setByUser) {
            super.value = newValue;
        } else {
            // ...
        }
    }
</fx:Script>
</s:NumericStepper>

Using Flex 4.1 if that matters.

Upvotes: 0

Views: 121

Answers (1)

Asad
Asad

Reputation: 1837

listen for the change event. It will solve your problem.

<s:HGroup>
        <s:NumericStepper change="trace('ns change')" value="{ns2.value}" minimum="{ns2.minimum}" maximum="{ns2.maximum}"/>
        <s:NumericStepper minimum="0" maximum="1000" id="ns2" />
    </s:HGroup>

The change event gets fired when an input component's value is changed by user interaction. If some part of your code is changing that component's value, the change event will not get fired.

Upvotes: 1

Related Questions