PDA

View Full Version : Right-click menu



tatocaster
21 Aug 2012, 3:51 AM
Can anybody help me? i need to capture right-click mouse and attach something, for example

Ext.create('Ext.menu.Menu', { width: 150,
height: 150,
margin: '0 0 10 0',
floating: false,
renderTo: Ext.getBody(),
items: [{
text: 'menu item 1'
},{
text: 'menu item 2'
},{
text: 'menu item 3'
}]
listeners: HERE i need to capture right click and do smth.
});


Thanks in advance!!!;)

redraid
21 Aug 2012, 4:33 AM
You can delegate event:


Ext.create('Ext.menu.Menu', {
width: 100,
height: 100,
floating: false, // usually you want this set to True (default)
renderTo: Ext.getBody(), // usually rendered by it's containing component
items: [{
text: 'icon item',
iconCls: 'add16'
},{
text: 'text item'
},{
text: 'plain item',
plain: true
}],
listeners: {
el: {
delegate: 'div.x-menu-item',
contextmenu: function (e, el) {
var item = Ext.getCmp(el.id);

console.log('Menu item %o', item);
e.preventDefault();
}
}
}
});

tatocaster
21 Aug 2012, 5:12 AM
sorry, not working... problem with listeners

redraid
21 Aug 2012, 5:41 AM
Working example http://jsfiddle.net/X3PNu/1/

tatocaster
21 Aug 2012, 9:30 AM
thanks ;)=D>