5 Replies Latest reply on Apr 23, 2007 9:06 AM by dimival

    Numeric Stepper - Disable Text Input

    Sam_Indianapolis
      I know this is a simple request but has anyone needed to disable the text input in a numeric stepper. I don't want it hidden, I just don't want people to be able to type text into it. Any ideas would be appreciated.

      Thanks
        • 1. Re: Numeric Stepper - Disable Text Input
          dimival Level 1
          I think that you might need to extend the NumericStepper class, and disable its private property inputField (which is the TextInput it uses).

          • 2. Re: Numeric Stepper - Disable Text Input
            Sam_Indianapolis Level 1
            Thanks for the response... Do you have any examples of how I would go about doing this? I've looked around and haven't found how to extend components.

            Thanks
            • 3. Re: Numeric Stepper - Disable Text Input
              dimival Level 1
              Ok i made a quick example and it worked so here it is. First create a new class that extends from NumericStepper:

              package test //you should change this for a package of your own, this is a test only

              {
              import mx.controls.NumericStepper;
              import mx.core.mx_internal ;

              use namespace mx_internal;

              public class NumStep extends NumericStepper
              {
              public function disableTextInput():void
              {
              inputField.enabled = false;
              }
              }
              }

              Once you have this, on you main application or wherever you are adding this NumericStepper do this:

              <local:NumStep id="myNumStep" creationComplete="myNumStep.disableTextInput()"/> //change local for whatever namespace you are using

              And there you go, now you have a numericStepper whose textInput is disabled, so you can only use the buttons to change its value.

              There's a document called "Creating and Extending Flex 2 Components", there you will find all the info you need on extending components

              Hope this helps you out, try it out and let me know if it works

              Diego
              • 4. Re: Numeric Stepper - Disable Text Input
                Sam_Indianapolis Level 1
                I put the code in from your example and it worked perfect. This should allow me to do what I need. I'm wondering... How did you find the property inputField on the numericStepper control? I may modify the class you made for other custom components.

                Thanks for your help
                • 5. Re: Numeric Stepper - Disable Text Input
                  dimival Level 1
                  When you install FDS you have access to the source code of it, so all i did was to check the NumericStepper.as file and there i found the inputField property.

                  Glad i could help :) don't forget to mark this and your other topic as answered

                  Diego