Results 1 to 3 of 3

Thread: Set the cursor position of htmleditor

  1. #1

    Default Set the cursor position of htmleditor

    Hi,
    I'm using HTML editor in my app,
    I do change the color of text after some characters, let's say after 20 characters.
    Some time it set cursor at the start by itself,
    Will you please tell me a way to set the position of the cursor .
    My code is


    Code:
    {
                            xtype:'htmleditor',
                            value:record.data.description,
                            height: 100,
                            width: 900,
                            name: 'instructionDescription',
                            enableColors: false,
                            enableFontSize: false,
                            allowBlank: false,
                            enableSourceEdit: false,
                            enableLinks: false,
                            enableFont: false,
                            enableAlignments: false,
                            enableLists:false,
                            colspan: 2,
                            style:{
                                'margin-left':'10px'
                            },
                            
                            listeners:{
                                change:function( Object, newValue, oldValue ){
    
    
                                    if(typeof(newValue) != 'string')
                                        return;
    
    
                                    var newVal = Ext.util.Format.stripTags(newValue);
                                    var oldVal = Ext.util.Format.stripTags(oldValue);
                                    var index = newValue.indexOf('<font color="#ffa500">');
                                    var velue = null;
                                    if(newVal == oldVal)
                                       return;
                                    if(index > -1){
                                        value = newValue.substr(0,index) + '<font color="#ffa500">' + newValue.substr(index + 22);
                                        this.setValue(value);
                                    }
                                    else{
    
    
                                        if(newVal.length > 20){
                                            newValue = newValue.replace('&nbsp;', " ");
                                            newVal = Ext.util.Format.stripTags(newValue);
                                            if(newVal.length < 21){
                                                return;
                                            }
                                            index = newValue.indexOf(Ext.util.Format.stripTags(newValue).substr(15,5));
                                            index += 5;
                                            value = newValue.substr(0,index) + '<font color="#ffa500">' +newValue.substr(index);
                                            value = value.replace('&nbsp;', " ");
                                            this.setValue(value);
                                        }
                                    }
                                },
                                afterrender:function(){
                                    var value = record.data.description;
                                    if(Ext.util.Format.stripTags(value).length > 20 ){
                                        var index = value.indexOf(Ext.util.Format.stripTags(value).substr(20));
                                        value = value.substr(0,index) + '<font color="#ffa500">' + value.substr(index);
                                        value = value.replace('&nbsp;', " ");
                                    }                                
                                    this.setValue(value);
                                }
                            }
                        }
    Please help me out,
    Thanks in advance

  2. #2

    Default

    *bump

  3. #3

    Default

    Any help please to set the cursor position ?
    Thanks in advance

Similar Threads

  1. Get cursor position or selection from HtmlEditor
    By rokd in forum Ext GWT: Discussion
    Replies: 0
    Last Post: 24 Feb 2011, 1:57 AM
  2. get cursor position in htmleditor
    By bhomass in forum Ext GWT: Discussion
    Replies: 1
    Last Post: 17 Feb 2011, 12:16 AM
  3. Help HtmlEditor get cursor position
    By g_papasavva in forum Ext 3.x: Help & Discussion
    Replies: 0
    Last Post: 22 Dec 2010, 7:38 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. [2.1] htmleditor cursor position under firefox
    By bobg in forum Ext 2.x: Bugs
    Replies: 1
    Last Post: 16 Jul 2008, 1:03 AM

Tags for this Thread

Posting Permissions

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