PDA

View Full Version : problem with initialization of menus



naveed_33
5 May 2014, 11:41 PM
The problem occurs in menu template. i am using the xtype menu with buttons and on the mouseover event on button i run the following command (menu.show()) and on mouseout i do something like (menu.hide()). but its always pointing to null. however if i click on the button once and the menu gets shown once. then when i do the mouse over and mouse out it works.

Gary Schlosberg
6 May 2014, 4:24 AM
Thanks for the report. In which version of ExtJS are you seeing this issue? Can you please post a runnable test case which reproduces the issue? You can use our Fiddle if you like:
https://fiddle.sencha.com/#home

naveed_33
6 May 2014, 5:28 AM
i cant put the real code as it belongs to the company where i work but i have just written an example of what the code that caused the problem looked like. i did find a way to go over it. but still this one does not work at least until you click on the button. i am using extjs4.2.2.
////////////////////////
//////////////////////////
////////////////////////
{
xtype: 'button',
Id:"Customer",
x: 160,
y: 120,
height: 150,
width: 180,
scale: 'large',// autoWidth : true, autoHeight : true,


cls:'Customercls',


// overCls: 'lang-de-button',




text: 'Customers',
menu: {
xtype: 'menu',
id: 'CustomerMenu',
width:180,
items: [
{
xtype: 'menuitem',
text: 'A'
},
{
xtype: 'menuitem',
text: 'B'
},
{
xtype: 'menuitem',
text: 'C'
}
]
},

listeners: {


mouseover: {






fn: me.onButtonMouseOver,
scope: me
},
mouseout: {
fn: me.onButtonMouseOut,
scope: me
}
}
/////////////////////////////
////////////////////////////
////////////////////////////
onButtonMouseOver: function(button, e, eOpts) {
var anotherbtn =Ext.get('CustomerMenu');
anotherbtn.show();


},


onButtonMouseOut: function(button, e, eOpts) {
var anotherbtn =Ext.get('CustomerMenu');

anotherbtn.hide();
}

Gary Schlosberg
6 May 2014, 6:38 AM
I believe the event you need is mouseleave, as menu items don't have a mouseout event.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.menu.Menu-event-mouseleave

naveed_33
6 May 2014, 8:00 AM
no i am generating the event for leaving the button and in this event i get the menu from its id using ext.get(id) function. when i pass over it before i have clicked on it, nothing happens. however when i click on it the menu gets initialized and then it works. for example

before clicking the button:
pass over the button: nothing happens
pass out of the button: nothing happens.
error in both cases "anotherbtn points to null"

after clicking the button:
pass over : menu appears
passout: menu dissappears