-
17 Jul 2008 9:29 AM #1
Select event on ColorMenu
Select event on ColorMenu
Hello.
I'm trying to create a colormenu and create an event when someone selects one color.
the code is the following:
it is all rendering well, but when I select one color, nothing happens.Code:var colormenu = new Ext.menu.ColorMenu(); colormenu.palette.colors = ["c6d9f1","f2dbdb","ddd9c3","fbd4b4","eaf1dd","dbe5f1","deb3b3","fff0c3","daeef3","fbcb90","c0c0cd","d7f297","ffb8d4","ffdc66","4edab2","9dedbb","ffa58a","fd77b4","e1d1c6","fffaaf"]; colormenu.on('select',function(colorpalette, color){ alert(color); }); var tb = new Ext.Toolbar('escolher_cor'); tb.add({ cls: 'x-btn-text bmenu', // icon and text class text:'Escolher Cor', menu: colormenu });
i get this on firebug:
if i remove the second line of the code, where I define the colorpalette, it works!Code:B.child("a.color-" + A) is null [Break on this error] Ext.ColorPalette=function(A){Ext.ColorPa...e=A;this.fireEvent("select",this,A)}}}); at ext-all.js (linha 63)
but i need to define it. is there any other way to do it in order to keep the select event working ?
anyone can help me on this ?
-
18 Jul 2008 1:08 AM #2
i tryed to create a ColorPalette and assign it to ColorMenu.palette property, but it doesn't work... the palette isn't assigned.
can anyone help me ?
edit:
i used the debug file to check the exact line where i get the error and it is the line number 13666:
el.child("a.color-"+color).addClass("x-color-palette-sel");
-
4 Jul 2009 6:12 AM #3
Is there a solution of this problem? I got exactly the same behaviour with extJS2 :-(
-
4 Jul 2009 6:30 AM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
You can't set the palette after the ColorPicker is created (it isn't a writable property!).
Use:
Code:var colormenu = new Ext.menu.ColorMenu({ colors: [ "c6d9f1","f2dbdb","ddd9c3","fbd4b4", "eaf1dd","dbe5f1","deb3b3","fff0c3", "daeef3","fbcb90","c0c0cd","d7f297", "ffb8d4","ffdc66","4edab2","9dedbb", "ffa58a","fd77b4","e1d1c6","fffaaf" ] });
-
4 Jul 2009 7:04 AM #5
Thank you for the quick reply. But this doesnt work also:
var ZitatColorMenu = new Ext.menu.ColorMenu({
colors: [
"c6d9f1","f2dbdb","ddd9c3","fbd4b4",
"eaf1dd","dbe5f1","deb3b3","fff0c3",
"daeef3","fbcb90","c0c0cd","d7f297",
"ffb8d4","ffdc66","4edab2","9dedbb",
"ffa58a","fd77b4","e1d1c6","fffaaf"
]
});
var ZitatMenu = new Ext.menu.Menu({
id: 'imageMenu',
items: [
{
text: 'Zitat löschen',
handler: function(){
...
} /* End of handler */
},
{
text:'Farbe',
menu:ZitatColorMenu
},
]
});
Its the same Error: "b.child("a.color-"+a) is null"

-
5 Jul 2009 12:11 AM #6Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 40
It does work, but you need to use uppercase colors:
Code:var ZitatColorMenu = new Ext.menu.ColorMenu({ colors: [ "C6D9F1","F2DBDB","DDD9C3","FBD4B4", "EAF1DD","DBE5F1","DEB3B3","FFF0C3", "DAEEF3","FBCB90","C0C0CD","D7F297", "FFB8D4","FFDC66","4EDAB2","9DEDBB", "FFA58A","FD77B4","E1D1C6","FFFAAF" ] });
-
28 Jan 2010 6:54 PM #7
The solution I adopt on the problem
The solution I adopt on the problem
I encountered this problem when I used ColorPalette in EXTJS 3.1.Finally I found that I assigned an wrong value to the value property .Here is my code:
var cp = new Ext.ColorPalette({
value: '993300'
,renderTo: 'pa'
});
cp.on('select', function(p,v){
Ext.Msg.alert('INFO',v);
});
You can try this format.
I used '336633' as the initial value of the value property so Firebug showed the same error as yours.


Reply With Quote