Change default line break key of TextArea

  1. #1

    Change default line break key of TextArea

    Is it possible to change default line break key of TextArea?

    I want to insert line break by Ctrl + Enter instead of Enter.

    Thank you.
  2. #2
    I have tried fireEvent, but still have problem.

    Actually I want to let user press "Enter" to jump to next control as press "TAB"
    But the problem is when when user press enter in the TextArea, it also jump to next control.
    I want to modify that press Ctrl + Enter for TextArea to jump to nect line

    So I add this JS on my form
    Ext.get(document.body).on('keydown', commonkeydown);
    
    function commonkeydown() {
        if (event.ctrlKey != 1) {
            if (event.keyCode == 13)
                event.keyCode = 9;
        } else {
            if (event.keyCode == 13) {
                //            var wsh = new ActiveXObject("WScript.Shell");
                //            wsh.SendKeys("{ENTER}");
                var customEvent = document.createEventObject()
                customEvent.bubbles = true;
                customEvent.cancelable = true;
                customEvent.view = window;
                customEvent.ctrlKey = false;
                customEvent.altKey = false;
                customEvent.shiftKey = false;
                customEvent.metaKey = false;
                customEvent.keyCode = 13;
                document.body.fireEvent("onkeydown", customEvent);  
            } 
        }
    
    }
    I try use fireEvent to simulate a "Enter" press. It works if I insert a breakpoint in the JS, and run it line by line.
    When I remove the breakpoint, try directly in my form it didn't work.

    Any idea? Thank you~
    Last edited by Vinci; Jun 19, 2013 at 5:33 AM.

Similar Threads

  1. [CLOSED] textarea with line numbers
    By bogc in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 27, 2011, 11:37 AM
  2. [CLOSED] TextArea: format default value
    By RomualdAwessou in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Oct 08, 2010, 11:42 AM
  3. [CLOSED] Dynamic Hyperlink adding HTML Line break after
    By rthiney in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 13, 2010, 2:09 PM
  4. [CLOSED] TextArea in Container doesn't line up to fields above
    By sdevanney in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 30, 2010, 5:45 PM
  5. [CLOSED] no line break in text area
    By Sharon in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Aug 07, 2009, 4:53 AM

Tags for this Thread

Posting Permissions