...

View Full Version : Why is the text editor here (vB) stopping me from preventDefault()?



cfec
06-05-2006, 04:27 AM
Here is a favlet to insert real tab characters by pressing the tab key on your keyboard in textarea elements.

Normally, pressing the tab key in a form element gives focus to the next page element, or to the next browser element, like with many UIs.

The script overrides this and gives back the text editing function of the tab key. It also inserts a button to toggle back and forth to the default behavior.

I still need to use the W3C event registration model in order for the object to be perfectly encapsulated within Rich Text Edit environments where keydown is often a registered event for textarea elements.

What I don't understand is why the text editor here is stopping me from preventDefault()? It works fine in IE with returnValue, but not in Firefox/Safari/Opera where I need to use preventDefault.

Here it is:
http://www.christianfecteau.com/echo/textedit/textedit_favlet.html

If you inject it here (on this board) and press the tab key in FF, the tab character is inserted in the textarea, but the focus is given to the next element in the form, which is what preventDefault() is supposed to avoid!

After a couple of hours of looking at the JS for the vB editor, I give up: I need help!

Thanks.

hemebond
06-10-2006, 09:33 AM
Works on FF Win (as your site states). Perhaps you should update this post to make it clear the problem is only on the Mac.

GJay
06-10-2006, 10:06 PM
it's the same on FF for Linux (Ubtuntu)...

cfec
07-28-2006, 11:38 PM
FF Win here: nothing is changed. The tab character is inserted correctly in the textarea but the focus is lost to the next form element, so you have to give the focus back to the textarea everytime in order to continue typing.

cfec
08-20-2006, 09:14 AM
Finally went for a timer and a reference to the textarea, stored in a custom property of the window object:


a[i].onkeydown = function(e)
{
window.TextEditFavlet_Tabber_tmp = this;
// insert tab character [...]
window.setTimeout('window.TextEditFavlet_Tabber_tmp.focus()',1);
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum