Link to home
Start Free TrialLog in
Avatar of mte01
mte01Flag for Lebanon

asked on

i like to append a text into a text area where the mouse caret is...

Hi,
i like to append a text into a text area where the mouse caret is,
and then set the mouse caret at the end of the text area.
can this be done in flash 7??

thanks
Avatar of Montoya
Montoya

a texbox component allows that, but Im not sure if that is what you mean. Just make sure the "editable" parameter is set to true.
Hi, also not sure what you mean.
Do you want the user to simply insert the cursor into the text field and type.
Or are you thinking along other lines?
Avatar of mte01

ASKER

Hi guys,
i have this button, that the user can click
if the original text was: 1234
and the mouse caret was after the 2,
and if the user clicked on this button: the text will become 12~34
it's like inserting text at a specific position, not at the end, i was looking now at the function Selection.getCaretIndex()
this will return the caret index. but i cant set the caret index of the text area, like after adding the character "~"  i want the mouse caret to be at the end of the text so that when the user start typing the text will be appended at the end.. dont know if this is clear, plz tell me if it's not and ill try to make it clearer...
Kind regards
SOLUTION
Avatar of blue-genie
blue-genie
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
past the following code in a new FLA's first frame and compile the swf
----------
this.createTextField("pos_txt", this.getNextHighestDepth(), 50, 20, 100, 22);
this.createTextField("content_txt", this.getNextHighestDepth(), 50, 50, 400, 300);
content_txt.border = true;
content_txt.type = "input";
content_txt.wordWrap = true;
content_txt.multiline = true;
content_txt.onChanged = getCaretPos;

var keyListener:Object = new Object();
keyListener.onKeyUp = getCaretPos;
Key.addListener(keyListener);

var mouseListener:Object = new Object();
mouseListener.onMouseUp = getCaretPos;
Mouse.addListener(mouseListener);

function getCaretPos() {
    pos_txt.text = Selection.getCaretIndex();
}
--------------

Rgds
Aneesh
Avatar of mte01

ASKER

thanks aneeshchopra
i can see the caret pos, the problem is that i need to set the caret pos, like i want when i click on a button to set the caret to the position 0 (or any number).
one more time thanks guys for the help for a big part of the problem is fixed.
Best regards,
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
***bowing to Aneesh***** thanks for saving me some time. I was about to try this. :)

Avatar of mte01

ASKER

:) thanks Aneesh it's perfect.
Welcome,
but you still haven't accepted the comments...