View Full Version : Another stupid question about context menu
enzhu
11-06-2007, 12:13 PM
Hi! Sorry that I got another stupid question about context menu here. I need to replace context menu in a window componet. it looks like:
<canvas debug="true">
<window name="testwins" title="testwin" height="300" width="400" bgcolor="red" closeable="true" resizable="true">
<handler name="oninit">
var newMenu = new LzContextMenu();
newMenu.hideBuiltInItems();
this.setContextMenu(newMenu);
</handler>
</window>
</canvas>
To my great surprise, I even can't make this work. :(
Could you give me some hints why it doesn't work? Thank you very much.
bruce
11-06-2007, 03:51 PM
I tried to use setContextMenu the other day, changing from my current method. It didn't work and I didn't feel like resolving it. I use setDefaultContextMenu and it works fine. I have my overall menu and then specific views change it. You might give that a shot. It wastes memory I suppose but given my app is already 130M, I don't think it matters. :/
Cheers
vernid
11-06-2007, 11:40 PM
Hi,
It is because the subviews doesn't inherite the parent menu and as a window is composed by different subview your menu is not set as you expected.
In fact the content of your window is in wframe.wcontent view.
Be aware if you add subviews your menu will be not available on them.
check also thread:
Please try this:
http://forum.openlaszlo.org/showthread.php?t=11059&highlight=ContextMenu
<canvas debug="true">
<window name="testwins" title="testwin" height="300" width="400"
bgcolor="red" closeable="true" resizable="true">
<handler name="oninit">
var newMenu = new LzContextMenu();
newMenu.hideBuiltInItems();
this.wframe.wcontent.setContextMenu(newMenu); </handler>
</window>
</canvas>
Regards
Dominique
bruce
11-07-2007, 12:18 AM
I wouldn't want to cycle through the subviews doing the assignment especially with views created via datasets. I handle this using the default menu setter, have one base menu and many other menus that are assigned as you cross a view/subview. Nothing is perfect but it works across 3.3 to 4.1.x.
Cheers
enzhu
11-08-2007, 06:01 AM
Thank you very much bruce and vernid.
bruce, 130MB? :eek: My code is only 800KB but I already have enough headache with it. :(
Locutus
02-28-2008, 08:51 AM
And into other component?
Ex: text?
<canvas debug="true">
<simplelayout/>
<text fontsize="26" text="Texttttttttt!!">
<handler name="oninit">
var cm = new LzContextMenu();
cm.addItem(cm.makeMenuItem('Custom example1', new LzDelegate(this, 'checkIt1')));
cm.addItem(cm.makeMenuItem('Custom example2', new LzDelegate(this, 'checkIt2')));
this.setContextMenu(cm);
</handler>
<method name="checkIt1">
Debug.write("Check1");
</method>
<method name="checkIt2">
Debug.write("Check2");
</method>
</text>
<window name="win" title="win" height="100" width="100" x="50" y="50" bgcolor="red">
<handler name="oninit">
var cm = new LzContextMenu();
cm.addItem(cm.makeMenuItem('Custom example1', new LzDelegate(this, 'checkIt1')));
cm.addItem(cm.makeMenuItem('Custom example2', new LzDelegate(this, 'checkIt2')));
this.wframe.wcontent.setContextMenu(cm);
</handler>
<method name="checkIt1">
Debug.write("Check1");
</method>
<method name="checkIt2">
Debug.write("Check2");
</method>
</window>
<view width="100" height="100" bgcolor="blue">
<handler name="oninit">
var cm2 = new LzContextMenu();
cm2.addItem(cm2.makeMenuItem('Custom example1', new LzDelegate(this, 'checkIt1')));
cm2.addItem(cm2.makeMenuItem('Custom example2', new LzDelegate(this, 'checkIt2')));
setContextMenu(cm2);
</handler>
<method name="checkIt1">
Debug.write("Check1");
</method>
<method name="checkIt2">
Debug.write("Check2");
</method>
</view>
</canvas>
Into view: work allways
Into window: work (using this.wframe.wcontent)
Into text: don't work
Using: OpenLaszlo 4.0.10 and swf8
Thanks!
PS: sorry for my English :rolleyes:
senshi
02-29-2008, 02:11 PM
This is a regression, see LPP-5533 (http://www.openlaszlo.org/jira/browse/LPP-5533).
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.