PDA

View Full Version : How to capture mouse cursor coordinates



tatocaster
22 Aug 2012, 5:48 AM
I have just wrote a right-click menu, but i cant capture mouse cursor coordinates. when i click on a right-button anywhere, my menu appears at different position. It didn't trace to a mouse. Is my question clear?

Thanks in advance;)

sword-it
22 Aug 2012, 6:09 AM
Hi tatocaster,

You can get the mouse cursor cordinate by event.getXY().



listeners:{
itemcontextmenu:function(view, record, item, index,event, options){
Ext.create (http://docs.sencha.com/ext-js/4-1/#!/api/Ext-method-create)('Ext.menu.Menu (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.menu.Menu)',{
width:100,
height:100,
margin:'0 0 10 0',
items:[{
text:'regular item 1'
},
{
text:'regular item 2'
},
{
text:'regular item 3'
}]
}).showAt(event.getXY());
}}

read API docs http://docs.sencha.com/ext-js/4-1/#!/api/Ext.EventObject-method-getXY