Hi Thomas,
I am sorry. This is really too much code. Could you please send your two
examples stripped down as much as possible as attachments which directly
work from our demo/test folder. Thanks.
Sebastian
Thomas Oeding schrieb:
Hello list,
i have a small problem with the QxMenu events. i want to build up my own
context menu dynamical
at runtime with different entrys (for many items with many different
contextmenus).
for this i use the code sniped Version 1 (bellow)
this version doesnt work.
version 2 (bellow too) works fine. i dont understand why.
the only difference is the location of the creation of the QxMenuButton.
version 1: in proto._createWidgets(), executed on class init
version 2: in proto._rebuildMenu(), executed on open/rebuild menu
i need version 1, because in version 2 each time the menu is opend the
QxMenubutton is recreated
(memory leak)
any hints in the right direction?
regards,
Thomas
Version 1:
-----
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"
/>
<title>Atom 1 @ qooxdoo :: demo</title>
<link type="text/css" rel="stylesheet" href="../demolayout.css"/>
<script type="text/javascript" src="../../script/qooxdoo.js"></script>
</head>
<body>
<script type="text/javascript" src="../demolayout.js"></script>
<div id="demoDescription">
<p>Context- Menu.</p>
</div>
<script type="text/javascript">
/* Class opens different Context menus */
function uiContextMenu() {
QxMenu.call(this);
this._widgetElements={}; // variable to store all widgets ever
generated
for later disposal
this._createWidgets(); // create, but not add
// create commands
this._execCmd = new QxCommand();
this._execCmd.addEventListener("execute", function(e) {
alert("click menue event");
this._clickMenu(e.getData().getUserData("cmd"));
}, this);
}
uiContextMenu.extend(QxMenu, "uiContextMenu");
proto._clickMenu = function (vCmd) {
alert("click menue function");
}
/* show the context menue */
proto.openMenue = function(e) {
this.setLocation(100, 100);
this._rebuildMenu(); // rearrange menu items
this.show(); // open menu
e.setPropagationStopped(true); // stop click event here
}
proto._rebuildMenu = function () {
this.removeAll(); // remove items
// this._widgetElements.newButton = new QxMenuButton("New", null,
this._execCmd);
this._widgetElements.newButton.setLabel("onother one, dynamic");
this.add(this._widgetElements.newButton);
}
/* creates all basic ui elements on startup */
proto._createWidgets = function() {
this._widgetElements.newButton = new QxMenuButton("New Static", null,
this._execCmd);
};
// --------------------
window.application.main = function()
{
var d = this.getClientWindow().getClientDocument();
contextMenu = new uiContextMenu();
d.add(contextMenu);
var test = new QxButton("Test");
// add context menue
test.addEventListener("contextmenu", function(e) {
contextMenu.openMenue(e);
});
test.setLocation(90,90);
d.add(test);
};
</script>
</body>
</html>
Version 2:
-----
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15"
/>
<title>Atom 1 @ qooxdoo :: demo</title>
<link type="text/css" rel="stylesheet" href="../demolayout.css"/>
<script type="text/javascript" src="../../script/qooxdoo.js"></script>
</head>
<body>
<script type="text/javascript" src="../demolayout.js"></script>
<div id="demoDescription">
<p>Context- Menu.</p>
</div>
<script type="text/javascript">
/* Class opens different Context menus */
function uiContextMenu() {
QxMenu.call(this);
this._widgetElements={}; // variable to store all widgets ever
generated
for later disposal
this._createWidgets(); // create, but not add
// create commands
this._execCmd = new QxCommand();
this._execCmd.addEventListener("execute", function(e) {
alert("click menue event");
this._clickMenu(e.getData().getUserData("cmd"));
}, this);
}
uiContextMenu.extend(QxMenu, "uiContextMenu");
proto._clickMenu = function (vCmd) {
alert("click menue function");
}
/* show the context menue */
proto.openMenue = function(e) {
this.setLocation(100, 100);
this._rebuildMenu();
this.show();
e.setPropagationStopped(true);
}
proto._rebuildMenu = function () {
this.removeAll(); // remove items
this._widgetElements.newButton = new QxMenuButton("New", null,
this._execCmd);
this.add(this._widgetElements.newButton);
}
/* creates all basic ui elements on startup */
proto._createWidgets = function() {
// this._widgetElements.newButton = new QxMenuButton("New", null,
this._execCmd);
};
// --------------------
window.application.main = function()
{
var d = this.getClientWindow().getClientDocument();
contextMenu = new uiContextMenu();
d.add(contextMenu);
var test = new QxButton("Test");
// add context menue
test.addEventListener("contextmenu", function(e) {
contextMenu.openMenue(e);
});
test.setLocation(90,90);
d.add(test);
};
</script>
</body>
</html>
--
View this message in context:
http://www.nabble.com/events-and-QxMenuButton-t1368936.html#a3671529
Sent from the qooxdoo-devel forum at Nabble.com.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel