سؤال

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.

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top