firefox you swine....
so it appears under certain circumstances firefox will play swapsies with you @ and " key. This is fine for some people, but others just can't seem to find the newly located @ key. When you have an email sign up form this can be a problem.
Lucky then that I have the solution...
first we need a method to run everytime a key is pressed. This will read the current text cursor (caret) position and return it as a number. We will then set the caret to be in the next position. This is exactly what flash does anyway, but we need to physically do this, to complement the hidden button off screen.
This hidden button will respond to certain key presses, namely the @ or " signs...
When these keys are pressed it will add a @ sign to the end of the input text box, and then because we have pressed a key, our earlier method will push the caret to after the @ sign... genius!
heres the code for the frame with the text box (n.b. sally is the var name of my input text box):
var Pos:Number;
function setCaret(n){
Selection.setSelection(n,n);
}
myListener = new Object();
myListener.onKeyDown = function(){
cursorPos = Selection.getCaretIndex(sally);
trace(cursorPos);
cursorPos=cursorPos+1;
setInterval(setCaret,0,cursorPos);
}
Key.addListener(myListener);
Then add this to a button off screen:
on(keyPress "@"){
sally=sally+"@";
}
on(keyPress '"'){
sally=sally+"@";
}
I'll post the fla up later...
Lucky then that I have the solution...
first we need a method to run everytime a key is pressed. This will read the current text cursor (caret) position and return it as a number. We will then set the caret to be in the next position. This is exactly what flash does anyway, but we need to physically do this, to complement the hidden button off screen.
This hidden button will respond to certain key presses, namely the @ or " signs...
When these keys are pressed it will add a @ sign to the end of the input text box, and then because we have pressed a key, our earlier method will push the caret to after the @ sign... genius!
heres the code for the frame with the text box (n.b. sally is the var name of my input text box):
var Pos:Number;
function setCaret(n){
Selection.setSelection(n,n);
}
myListener = new Object();
myListener.onKeyDown = function(){
cursorPos = Selection.getCaretIndex(sally);
trace(cursorPos);
cursorPos=cursorPos+1;
setInterval(setCaret,0,cursorPos);
}
Key.addListener(myListener);
Then add this to a button off screen:
on(keyPress "@"){
sally=sally+"@";
}
on(keyPress '"'){
sally=sally+"@";
}
I'll post the fla up later...