PDA

View Full Version : Incorrect behavior of context menu



blackcat
1 Dec 2010, 12:45 AM
I create simple toolbar with menu and for all item added context menu. When I click to Menu and choose one of item from 'another menu' and click right button - the context menu is appear. When I click right button on another item the context menu appear behind the menu. Is it a bug or I doing something wrong?



Ext.onReady(function() {
Ext.QuickTips.init();
var views = new ViewsMenu();
});


function ViewsMenu() {
this.init();
}

ViewsMenu.prototype = {
init: function() {

var anotherMenu = new Ext.menu.Menu({
items:[
{text: 'one'},
{text: 'two'},
{text: 'three'}
]
});

var menu = new Ext.menu.Menu({
id: 'mainMenu',
style: {
overflow: 'visible'
},
items: [
{text: 'One'},
{text: 'Two'},
{text: 'Three'},
{
text: 'Another menu',
menu: anotherMenu
}
]
});

var menus = [anotherMenu];
menus.push(menu);
for (var k = 0; k < menus.length; k++) {
var m = menus[k];
if (m.items) {
for (var i = 0; i < m.items.length; i++) {
var item = m.items.itemAt(i);
if (item.rendered) {
item.getEl().on('contextmenu', this.onContextMenu, item);
} else {
item.on('render', function(o) {
o.getEl().on('contextmenu', this.onContextMenu, o);
}, this);
}
}
}
}

var tb = new Ext.Toolbar();
tb.render('toolbar');

tb.add({
text:'Menu',
menu: menu
});

tb.doLayout();
} ,

onContextMenu : function(e, el) {
e.preventDefault();

var item = this;
var id = 'views-saved-context-menu';
var contextMenu = Ext.menu.MenuMgr.get(id);
if (contextMenu) {
contextMenu.destroy();
}

contextMenu = new Ext.menu.Menu({
id : id,
allowOtherMenus : true,
items: [
{
text:'Remove',
scope: this
}
]
});

contextMenu.showAt(e.getXY());
}
}




http://i.piccy.info/i5/70/40/784070/untitled_240.jpg