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

06-05-2006, 03: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:

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!


06-10-2006, 08: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.

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

07-28-2006, 10: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.

08-20-2006, 08: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 [...]