1 Reply Latest reply on Jun 14, 2006 1:39 PM by Newsgroup_User

    Input formatting of TextInput for Numbers

    is2
      What is the proper way to format Numbers and for that matter when using the TextInput?

      Example would be to format for $999,999.99 dollars but still allow the user to properly input a new number and still maintain afterward the dollar formatting. I may be missing something ( which is quite likely ) but there needs to be a distinction between the value of the TextInput and the formatted display text.

      This has two sides to the equation.
      1. Display the number as needed.
      2. When user starts input of a number, change to a number entry type process.
      3. Redisplay the number formatted properly after the user exits the TextInput component.

      Also, I am having trouble when I try to use the input in calculations after the value has been formatted if I use the TextInput.text.

      Seems like a nobrainer since we can do so many other amazing things in the Flex 2.

      Thanks ahead of time.

        • 1. Re: Input formatting of TextInput for Numbers
          Level 7
          The edit controls don't have the built-in ability to detect typing and change
          their contents. You could probably write a focus= handler to detect that the
          control has focus, and change its contents to allow editing.

          But probably a better way would be to start with some fancy controls written
          by Ely Greenfield on the Flex team.
          http://www.quietlyscheming.com/blog/components/ipe-controls/ has some controls
          he wrote, "In Place Editing (IPE) Controls". Try the sample linked from that
          page. (I'd suggest starting by checking ALL the boxes in the left-hand
          column, and then going from there.) His controls do a glitzy visual
          transition, but even if you don't want that, you could easily modify his code
          to do no transition if that's what you prefer.

          --
          Mike Morearty
          Developer, Flex Builder team
          http://www.morearty.com/blog