Groups | Blog | Home
all groups > flash actionscript > june 2005 >

flash actionscript : KeyPress <enter> won't work when cursor is in textinput component


kglad
6/17/2005 12:00:00 AM
if your textfield is non-html enabled and has instance name tf, you can use:

tf.onChanged = function() {
if (tf.text.charAt(tf.text.length-1) == "\r") {
trace("Do this stuff");
}
Danny Mac
6/17/2005 12:00:00 AM
Yeah, i gave that a try. It's actually a textInput component (not textfield,
but I don't know if that makes a difference). I still don't think it likes the
fact that the focus is still in typing text in the component.
Danny Mac
6/17/2005 1:44:07 PM
Hi there,

I have a textInput component and a button that submits the contents of that
textInput. What I'm trying to do is type whatever I want in the textInput and
submit it by hitting the "enter" button. So, I put this code on the button:

on (release, keyPress "<enter>")
{
trace("Do this stuff");
}

It's simple and it should work. What I found out was, I have to click outside
of the textInput to trigger the button with the enter key. In other words,
I've got to take the focus off of the textInput to to submit the info. But, if
I'm having to click outside the textInput to submit the data with <enter>, then
I might as well just click on the <enter> button with my cursor which is what
I'm trying to avoid. Anyone have any ideas?

Thanks,
Danny
kglad
6/18/2005 12:00:00 AM
if you're using a component you can use:

myo = new Object();
myo.onKeyDown = function() {
if (Key.isDown(Key.ENTER)) {
trace("Do this stuff");
}
};
AddThis Social Bookmark Button