我正在研究如何在使用Sencha的文本字段中获得鼠标位置



这是我的第一个帖子,如果需要的话,我可以补充更多的细节。

我希望得到光标的xy位置时,无论是小时,分钟或秒单击。我希望使用步进的位置采取相应的行动。当前代码只是以undefined作为响应。我得到未定义,因为我使用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",

您可以为el(或inputEl)添加mousemove事件侦听器,例如:

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

工作示例:https://fiddle.sencha.com/#fiddle/uke

Stack Overflow是惊人的!这两天我绞尽脑汁想弄明白这事。多亏了@CD。我可以使用mousedown:来确定单击框中的位置,并使用event.clientX来捕获X位置。在extjs 4.2.2中你可以使用e.getX()

最新更新