Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Textfield select text issues

Status
Not open for further replies.

draigGoch

Programmer
Feb 10, 2005
166
0
0
GB
I have an input textfield which users can add text to original, and also select portions of the text. But I want the users to be able to select text, then when the text is still selected, click on a button to copy selected text into another textfield.

The problem arises when clicking on the button, the focus changes and therefore I lose track of which parts of the text was selected.

So the solution is a way that selected text is remembered before losing focus.

Any ideas?


A computer always does what you tell it to, but rarely does what you want it to.....
 
There may be a better solution but one way is to capture the selection on every enter frame:
Code:
var textToCopy:String = new String();
this.onEnterFrame = function():Void  {
	textToCopy = tf1.text.substring(Selection.getBeginIndex(), Selection.getEndIndex());
};
tf1.onKillFocus = function():Void  {
	tf2.text = textToCopy;
};

Kenneth Kawamoto
 
I didn't think of doing it that idea - thanks, that might work!

A computer always does what you tell it to, but rarely does what you want it to.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top