PDA

View Full Version : [FIXED][3.0rc3] Menu beforeshow event not firing



flylaputa
6 Jul 2009, 5:37 AM
Ext version tested:

Ext 3.0 RC3Browser versions tested against:

IE7
FF3Operating System:

WinXP ProDescription:

'beforeshow' event not firing.Test Case:


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../../../ext-3.0-rc3/resources/css/ext-all.css">
<script type="text/javascript" src="../../../ext-3.0-rc3/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../../ext-3.0-rc3/ext-all-debug.js"></script>
<title id="page-title">Title</title>
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = '../../../ext-3.0-rc2/resources/images/default/s.gif';
Ext.onReady(function() {
Ext.QuickTips.init();
var menu = new Ext.menu.Menu({
items: [
{
text: 'An item'
}
]
});
menu.on('beforeshow', function(menu) {
alert('beforeshow event');
});
var root = new Ext.tree.TreeNode({
text: 'A Node'
});
var treePanel = new Ext.tree.TreePanel({
contextMenu: menu,
root: root
});
treePanel.on('contextmenu', function(node, evt) {
menu.showAt(evt.getXY());
evt.stopEvent();
});
var mainPortal = new Ext.Viewport({
title: 'Main Portal',
layout: 'fit',
items: [treePanel]
});
});
</script>
</head>
<body>
</body>
</html>

See this URL : http://

Steps to reproduce the problem:

Right click on the tree node 'A Node'.The result that was expected:

An alert box with the message 'beforeshow event'.The result that occurs instead:

The menu is shown.Screenshot or Video:

Debugging already done:

nonePossible fix:

Condor
6 Jul 2009, 5:41 AM
Suggested fix: Move beforeshow call from show() to showAt().

Ext.override(Ext.menu.Menu, {
show : function(el, pos, parentMenu){
if(this.floating){
this.parentMenu = parentMenu;
if(!this.el){
this.render();
this.doLayout(false, true);
}
//if(this.fireEvent('beforeshow', this) !== false){
this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign, this.defaultOffsets), parentMenu, false);
//}
}else{
Ext.menu.Menu.superclass.show.call(this);
}
},
showAt : function(xy, parentMenu, _e){
if(this.fireEvent('beforeshow', this) !== false){
this.parentMenu = parentMenu;
if(!this.el){
this.render();
}
this.el.setXY(xy);
if(this.enableScrolling){
this.constrainScroll(xy[1]);
}
this.el.show();
Ext.menu.Menu.superclass.onShow.call(this);
if(Ext.isIE){
this.layout.doAutoSize();
if(!Ext.isIE8){
this.el.repaint();
}
}
this.hidden = false;
this.focus();
this.fireEvent("show", this);
}
}
});

evant
6 Jul 2009, 5:44 AM
Possible. The behaviour of components is that show will fire the beforeshow event. In this case, you're calling showAt directly, which isn't show().

flylaputa
7 Jul 2009, 3:24 AM
Hi~~

I just downloaded the realease version of ExtJS 3.0.0 and I am still getting the same behaviour. So should I manually override the methods or will this be fixed in some future patch?

Many thanks

evant
7 Jul 2009, 9:03 PM
I think what Condor suggested makes sense. Show will either call the superclass show method or showAt, so moving beforeshow over would be consistent.

evant
7 Jul 2009, 11:16 PM
This has been committed to the trunk.