View Full Version : newbie / rightclick tree
maroch
08-05-2007, 02:00 AM
hi, i want to add a new right-clicking option in my tree, i did something like that
<tree ...>
<contexmenu>
</contexmenu>
<tree ..>
</tree>
</tree>
but the new contexmenu is only working with root, i want this menu for all nodes! In Developer's Guide is to simple example!?!
HELP
Evangelus
08-05-2007, 04:28 AM
Context menus only attach to the object they are specifically attached to; they do not propagate to that objects children. That has to be done manually.
This is how I solved that problem in my application: OpenLaszlo: a way to propagate context menus (http://philwallach.com/?p=76). I am not sure how much that would help you.
I am interested in a better way of doing this.
HTH
Phil
senshi
08-05-2007, 02:37 PM
I guess I'd set the context-menu by a oninit-handler.
BTW you've used a "<contextmenu>"-tag. Which version of OpenLaszlo do you use, because this cannot be done in OL4.0.3. (At least I cannot do this with OL4.0.3 ...) So I've written my own class which supports creating contextmenus by tag.
<canvas debug="true">
<include href="context_menu_for_tree_lib.lzx" />
<dataset name="ds" >
<root text="root" >
<node text="node1" >
<node text="node1.1" isleaf="true" />
<node text="node1.2" isleaf="true" />
</node>
</root>
</dataset>
<tree datapath="ds:/root" showroot="true" text="$path{'@text'}" >
<contextmenu>
<contextmenuitem caption="Add" />
<contextmenuitem caption="Delete" />
</contextmenu>
<handler name="oninit" >
this.setTreeContextMenu(this, this.getContextMenu());
</handler>
<method name="setTreeContextMenu" args="tree,cm" >
tree.item.setContextMenu(cm);
tree.item.treeitem.setContextMenu(cm);
tree.item.treeitem.expander.setContextMenu(cm);
tree.item.treeitem.expander.expander.setContextMen u(cm);
tree.item.treeitem.icon.setContextMenu(cm);
tree.item.treeitem.icon.icon.setContextMenu(cm);
tree.item.treeitem.text.setContextMenu(cm);
</method>
<tree datapath="node" text="$path{'@text'}" isleaf="$path{'@isleaf'}" >
<handler name="oninit" >
var root = this.getRoot();
var cm = root.getContextMenu();
root.setTreeContextMenu(this, cm);
</handler>
</tree>
</tree>
</canvas>
maroch
08-06-2007, 12:00 AM
using L4.0.2, I have download some contexemenu.lzx (from this forum), i don't know how to write own contexmenu!!!
maroch
08-06-2007, 02:01 AM
would you tell me something about your context_menu_for_tree_lib.lzx file ???? super.thx
senshi
08-06-2007, 04:54 AM
Right now I'm at office, but I can post that file later this evening when I'm at home. Should be in four to five hours.
senshi
08-06-2007, 11:52 AM
Attached my version of "<contextmenu>".
It supports SWF and DHTML, but it is OL4.x-only.
senshi
08-06-2007, 12:11 PM
Also added the library to the official JIRA-Task for this issue: "LPP-834" (http://www.openlaszlo.org/jira/browse/LPP-834).
maroch
08-06-2007, 01:10 PM
thx ! Dziękuje!
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.