Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Why is the text editor here (vB) stopping me from preventDefault()?

    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...it_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.
    Last edited by cfec; 06-05-2006 at 04:29 AM.

  • #2
    Senior Coder
    Join Date
    Jul 2004
    Location
    New Zealand
    Posts
    1,315
    Thanks
    0
    Thanked 2 Times in 2 Posts
    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.
    Forget style. Code to semantics. Seperate style from structure, and structure from behaviour.
    I code to specs, and test only in Firefox (unless stated otherwise).

  • #3
    Senior Coder
    Join Date
    Sep 2005
    Posts
    1,791
    Thanks
    5
    Thanked 36 Times in 35 Posts
    it's the same on FF for Linux (Ubtuntu)...

  • #4
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Finally went for a timer and a reference to the textarea, stored in a custom property of the window object:

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •