Results 1 to 4 of 4

Thread: Cursor position

  1. #1
    Sencha User
    Join Date
    Sep 2015
    Posts
    11
    Answers
    1

    Default Answered: Cursor position

    Cursor position

    HI , I need to set cursor position at the end after every onChange event .


    Ext.application({
    name: 'Fiddle',


    launch: function() {


    Ext.create('Ext.form.HtmlEditor', {
    width: 580,
    height: 250,
    enableColors: false,
    enableAlignments: false,
    enableFont: false,
    enableFontSize: false,
    enableFormat: false,
    enableLinks: false,
    enableLists: false,
    enableSourceEdit: false,
    renderTo: Ext.getBody(),
    maxAllowed: 5,
    listeners: {
    change: function(he, newVal ,e) {
    var regex = /(<([^>]+)>)/ig
    var clearVal = newVal.replace(regex, "");
    if (clearVal != this.clearVal) {
    if (clearVal.length >= this.maxAllowed) {
    this.setValue(clearVal.substr(0, this.maxAllowed) + '<font color="#ff0000">' + clearVal.substr(this.maxAllowed, clearVal.length) + '</font>')
    }
    }
    this.clearVal = clearVal;

    }
    }
    });


    }
    });


    Thanks in advance

  2. ANSWERED..Finally Got by exploring n htmlEditor src classes.

    listeners: {
    change: function(he, newVal) {
    var regex = /(<([^>]+)>)/ig
    var clearVal = newVal.replace(regex, "");
    clearVal = Ext.util.Format.htmlDecode(clearVal);
    if (clearVal != this.clearVal) {
    if (clearVal.length >= this.maxAllowed) {
    he.relayCmd('backcolor', '#ff0000');// Add this..
    }
    }
    this.clearVal = clearVal;
    //this.win.getSelection().getRangeAt(0).
    }
    }

  3. #2
    Sencha User yeghikyan's Avatar
    Join Date
    Mar 2009
    Location
    München
    Posts
    574
    Answers
    99

    Default

    Where exactly at the end?
    You can get mouse position from the following code example:

    "The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague." – Edsger W. Dijkstra

  4. #3
    Sencha User
    Join Date
    Sep 2015
    Posts
    11
    Answers
    1

    Default HtmlEditor Cursor

    Hi , Thanks for the reply , but instead of the mouse Cursor , i need to set the htmleditor text cursor at the end on every onChange event .
    for eg.In the current code if i type 12345 , after '5' if i type '6789...' htmlEditor cursor set to the position 0 (i.e. at the begining , result = 987612345) I need result at the END i.e. 123456789......

    HOpe i am clear this time .

  5. #4
    Sencha User
    Join Date
    Sep 2015
    Posts
    11
    Answers
    1

    Default

    ANSWERED..Finally Got by exploring n htmlEditor src classes.

    listeners: {
    change: function(he, newVal) {
    var regex = /(<([^>]+)>)/ig
    var clearVal = newVal.replace(regex, "");
    clearVal = Ext.util.Format.htmlDecode(clearVal);
    if (clearVal != this.clearVal) {
    if (clearVal.length >= this.maxAllowed) {
    he.relayCmd('backcolor', '#ff0000');// Add this..
    }
    }
    this.clearVal = clearVal;
    //this.win.getSelection().getRangeAt(0).
    }
    }

Similar Threads

  1. Cursor Position in TextField
    By bballiet in forum Ext 3.x: Help & Discussion
    Replies: 14
    Last Post: 19 Oct 2017, 8:17 AM
  2. Set Cursor Position
    By noath in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 1 Sep 2015, 5:04 AM
  3. How to set the cursor position in the textfield
    By srinivasboda in forum Ext: Q&A
    Replies: 2
    Last Post: 11 Sep 2012, 5:34 AM
  4. [3.1.1] HtmlEditor cursor position?
    By danellison in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 8 Jun 2010, 1:14 AM
  5. Is there a way to set the cursor position for TextField?
    By obender in forum Community Discussion
    Replies: 0
    Last Post: 4 Jun 2008, 9:59 AM

Posting Permissions

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