PDA

View Full Version : ColorMenu as submenu



tomearly
10 May 2011, 11:15 PM
Hi,

I'm using an Ext.menu.ColorMenu as a context menu item on right clicking on a tree.

Each item within the tree can use this submenu.

However once i've selected a colour for one item in the tree, the previous colour is still selected in the colour menu and I can't reselect it again, but I can choose a different colour.

Below is the code that am I using. Is this the correct method, and if so is there a way to deselect the chosen colour in the colour menu?


var colorMenu = new Ext.menu.ColorMenu({
handler: function(cm, color){
//my code here
}
});

var menu = new Ext.menu.Menu({
id: 'mainMenu',
style: {
overflow: 'visible'
},
items: [
{
text: 'Choose a Color',
iconCls: 'color-picker-icon-small',
menu: colorMenu
}
]
});

MenuPanel = function(title,treedata) {
MenuPanel.superclass.constructor.call(this, {
border: true,
autoScroll: true,
tbar: deviceToolbar,
animate: false,
rootVisible:false,
collapseMode:'mini',
collapsed:false,
lines: true,
useArrows: true,
loader: new Ext.tree.TreeLoader(),
// cls: 'menu-tree',
root: new Ext.tree.AsyncTreeNode({
id:'source'
}),
listeners: {
contextmenu: function(node,e){
var analog = /analog/gi;

if(node.parentNode.id.match(analog))
{
if(node.attributes.checked === true)
{
var nodeidArray = node.id.split('^');
var graphid = nodeidArray[1];
selectedContextGID = graphid; //used in colorMenu function

node.select();
menu.contextNode = node;
menu.showAt(e.getXY());
}
}
}
}
})
};

tomearly
16 May 2011, 12:59 AM
Any ideas on this?