2 Replies Latest reply on Apr 20, 2007 8:59 PM by ebeaulieu

    Set cursor in a textinput

    ebeaulieu
      In this example, the focus is set to the phoneInput object but the cursor in this textinput is not set. How can I do this?
      Thank you!

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application
      xmlns:mx=" http://www.adobe.com/2006/mxml"
      viewSourceURL="src/FormatterSimple/index.html"
      width="310" height="210"
      initialize="focusManager.setFocus(phoneInput);"
      >

      <mx:PhoneFormatter id="phoneDisplay"
      formatString="(###) ###-####"
      />

      <!-- User interface -->

      <mx:Panel
      title="Using a formatter in an item renderer"
      paddingLeft="10" paddingRight="10" paddingBottom="10" paddingTop="10"
      >
      <mx:Text text="Enter a phone number, including{&apos;\r&apos;}the area code{&apos;\r&apos;}e.g., 2025558721:"/>
      <mx:TextInput id="phoneInput" width="100%"/>

      <!-- Display the formatted phone number -->
      <mx:Text text="{&apos;Formatted: &apos;+phoneDisplay.format(phoneInput.text)}"/>
      </mx:Panel>
      </mx:Application>
        • 1. Re: Set cursor in a textinput
          netsesame
          you should set the focus in creatCompleate event, not initialize. for, when initialize, the children components are not created yet.
          • 2. Re: Set cursor in a textinput
            ebeaulieu Level 1
            I tried this and it doesn't work!

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application
            xmlns:mx=" http://www.adobe.com/2006/mxml"
            viewSourceURL="src/FormatterSimple/index.html"
            width="310" height="210"
            creationComplete="focusManager.setFocus(phoneInput);"
            >

            <mx:PhoneFormatter id="phoneDisplay"
            formatString="(###) ###-####"
            />

            <!-- User interface -->

            <mx:Panel
            title="Using a formatter in an item renderer"
            paddingLeft="10" paddingRight="10" paddingBottom="10" paddingTop="10"
            >
            <mx:Text text="Enter a phone number, including{&apos;\r&apos;}the area code{&apos;\r&apos;}e.g., 2025558721:"/>
            <mx:TextInput id="phoneInput" width="100%"/>

            <!-- Display the formatted phone number -->
            <mx:Text text="{&apos;Formatted: &apos;+phoneDisplay.format(phoneInput.text)}"/>
            </mx:Panel>
            </mx:Application>