View Full Version : Moving cursor to top of textfield
Caimin
05-26-2005, 12:34 PM
I'm building a chat system in Flash. I've got a KeyListener setup so users can send messages just by hitting the enter key.
Trouble is, after hitting enter, the cursor in the textfield moves to the second line, even though all the text has been removed.
I'm looking for a way to either prevent the newline being created in the first place or to remove it after it happens. I've tried everything I can think of including setting the chat textfield text to "" and removing the focus away from the chat input textfield then replacing it.
Can't seem to find a way of removing the extra line or to shift the cursor back up to the top.
eclection
05-26-2005, 01:47 PM
try turning the multiline ability off for that textfield
Caimin
05-26-2005, 02:01 PM
Nice idea, which I hadn't thought of, but it's not working.
Another idea I had was to use 'restrict' to prevent ENTER getting into the textfield:
You can use the \u escape sequence to construct restrict strings. The following code includes only the characters from ASCII 32 (space) to ASCII 126 (tilde).
my_txt.restrict = "\u0020-\u007E";
...but I can't find the code for the ENTER key. grrr.
eclection
05-26-2005, 02:03 PM
Flash does not capture then ENTER key, sorry
eclection
05-26-2005, 02:04 PM
sorry for double post, but what you can try is to search for \n in the textfield, ie the root user hit enter using the onChange function, then send, and delete text accordingly
Caimin
05-27-2005, 07:58 AM
Thanks but I couldn't get that to work either - there doesn't seem to an \n or \r going into the textfield.
In the end, I switched to a single-line textfield and it works fine. Would have preferred to have used a multiline field... but it's not a big deal.
Thanks again for your help.
popupbob
06-14-2006, 02:34 AM
..by reading your post and not able to see any script from your chat..
It seems like you have a bug somewhere.. the input textbox wouldnt automaticly add a newline unless its stated somewhere. Perhaps theres a \n or \r added where is shouldnt.
Would be nice to see part of the script.. Im working a lot with my own chat inputtextbox at the moment, and its filled with \n and \r issues.. also it has a lot with cpos (input cusor _x-position).
Im trying to change the input blinking cursor, and it works pretty good, besite from a minor bug (the cursor keeps going to the right when you type long sentences) :(
Anyway, I posted a note on your site for further contact :) - hope to hear from you Caimin.
Best regards, Popupbob ;)
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.