sponsored ads

flash as3 adding focus listener to an input text field

sponsored ads

when is try to add focus listener to an input text filed, there is something wrong happened. i have never meet this case,i don't know what's wrong, can you help me ? Asked May, 03 2011
add commentflag 

sponsored ads

answer this question

What you want to do is check if the user is highlighting or if the box was already highlighted since last focus, and if not, stop flash player from putting the carat at the location clicked with event.preventDefault() function, and then set selection from beginning to end. Event.preventDefault() is a sneaky little function you call right on the event object in your event handler, and it prevents whatever the default actions would be for that event (in this case, clear selected text and place carat)

as3 code example:

// assuming you have a textbox input called _myTextInputBox

import flash.events.FocusEvent;
import flash.events.MouseEvent;
import flash.text.TextField;

_myTextInputBox.addEventListener(MouseEvent.CLICK, onClickTextBox);
_myTextInputBox.addEventListener(FocusEvent.FOCUS_OUT, onTextBoxLoseFocus);

var _highlightTextOnClick:Boolean = true;

function onClickTextBox(e:Event):void {

var didUserHighlight:Boolean = Boolean(e.target.selectionBeginIndex != e.target.selectionEndIndex);

if ( _highlightTextOnClick && !didUserHighlight) {
e.preventDefault();
e.target.setSelection(0, e.target.text.length);
_highlightTextOnClick = false;
}

}

function onTextBoxLoseFocus(e:FocusEvent):void
{
_highlightTextOnClick = true;
}

The source:http://www.onegiantmedia.com/flash-flex-as3---how-to-select--highlight-all-text-in-an-input-text-field-on-click Answered Jun, 14 2011
vote up 1 vote down

1,Select the input text,
2,push Ctrl+F3
3, click the drop-down menu beside it
4,choose it. Answered Jun, 24 2011
vote up 1 vote down

Hello,

Select the input text, push Ctrl+F3 to open the (Properties) panel, look for (Paragraph) then (Behavior) click the drop-down menu beside it, choose (Multiline). and you're good to go.

 

Abdellatif Rochdi.

Answered Nov, 06 2010
vote up 0 vote down

Your Answer

community wiki:

The Verified Code is to stop spamming. It will be hidden once your reputation reached 100.
or
Create one

Options

sponsored ads

Download related software from AFC

Focus Audio Converter 3.2

Last Updated: Mar 16, 2011
License: Shareware
Filesize: 9.41MB

Continue to downloadPower by Afreecodec.com