0

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.

zero323
  • 322,348
  • 103
  • 959
  • 935
P Varga
  • 19,174
  • 12
  • 70
  • 108

1 Answers1

1

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.

Asad
  • 1,817
  • 16
  • 23
  • is it the `Event.CHANGE` event that I need? And how do I get the new value? – P Varga Jun 18 '13 at 09:39
  • 1
    use `NumericStepper(event.currentTarget).value` to get the new value entered. – Asad Jun 18 '13 at 11:54
  • 2
    CHANGE is a change in value due to user interaction. VALUE_COMMIT is fired from programmatic changes. – Nathan Jun 18 '13 at 12:48
  • BTW, did you know that specifically for `NumericStepper`, this is actullay not a good solution because that class is buggy? https://issues.apache.org/jira/browse/FLEX-17361 – P Varga Jun 18 '13 at 13:36