Search code examples
javascriptextjscursorcursor-position

I am looking into how to get the mouse position in a text field using Sencha


This is my first post, I can fill in further details if needed.

I am looking to get the xy position of the cursor when either Hour, Minute or Seconds are clicked. I am looking to use the positions for the stepper to act accordingly. The current code just responds with undefined. I am getting undefined because I am using extjs 4.2.2

      {
        xtype: 'spinnerfield',
        itemId: 'time',
        name: 'intime',
        width: 125,
   listeners: {
    mousemove: {
        element: 'el',
        fn: function(e){
           var event = e.event;
           console.log(event.clientX);    
        }
    }
},
     step:1,
     value:"11:11:21",

Solution

  • You can add a mousemove event listener to the el (or inputEl), for example:

    xtype: 'textfield',
    listeners: {
        mousemove: {
            element: 'el',
            fn: function(e){
               console.log(e.event);    
            }
        }
    }
    

    A working example: https://fiddle.sencha.com/#fiddle/uke