Skip to main content
Inspiring
September 24, 2009
Answered

How to activate TextFlow without clicking?

  • September 24, 2009
  • 1 reply
  • 822 views

Hi there,

I am using the TextLayout framework to display Unicode text in AS3 and it's working well, mostly.  I have a registration form and I want to make it so that the user can hit tab to move between the input fields. 

I have been trying to use setFocus() on the EditManager of the TextFlow - and this works a treat if I have already clicked on the TextFlow input field in question.  However if I don't click on the TextFlow first to 'activate' it, the setFocus() call sets the focus property correctly but the actual input element is not focussed.  How can I set focus to a TextFlow input field without it being clicked first?

To reiterate, if I click on all the fields individually then I can tab fine from field to field - but until I've clicked on a field the call to its setFocus() method just seems to do nothing.  After a click the very same call works fine.

This also seems to happen in the examples provided by Adobe - I have downloaded the latest version of the Flex SDK (4.0.0.7129) and yet the problem still persists.

Any help greatly appreciated - I'm almost at the end of my tether!

This topic has been closed for replies.
Correct answer rdermer

The following works for me:

Assume you've created a textFlow, attached a SelectionManager composed and displayed it.

var im:ISelectionManager = textFlow.interactionManager;

im.selectRange(0,5);
im.refreshSelection();
im.setFocus();

Are you missing the refresh call?

Hope that helps,

Richard

1 reply

rdermerCorrect answer
Adobe Employee
September 24, 2009

The following works for me:

Assume you've created a textFlow, attached a SelectionManager composed and displayed it.

var im:ISelectionManager = textFlow.interactionManager;

im.selectRange(0,5);
im.refreshSelection();
im.setFocus();

Are you missing the refresh call?

Hope that helps,

Richard

Camussx
Inspiring
September 24, 2009

In the last build you can replace

im.selectRange(0,5);

for:

im.setSelection(0, 5);

and it works fine...!!!