View Full Version : clicking tree node vs. click tree node text?
jstretch
01-17-2006, 10:49 AM
Is it possible to create a different onclick method for a tree node's icon and a tree node's text?
eg: Have it expand and collapse when you click the icon, and have it do something else when you click on the text?
<tree text="$path{'asdf'}" />
I tried having no text and adding a text element in the tree, but I cant get it to align to the side of the icon. It always, of course, encapsulates it inside the node.
<tree>
<text>cant get this to align next to icon
<method event="onclick"></method>
</text>
</tree>
jcmaxx
01-17-2006, 01:54 PM
Is it possible to create a different onclick method for a tree node's icon and a tree node's text?
It is possible but you have to modify the source code for the tree component. For instance, I've made a simple change which keeps a parent tree from opening when the text element is single-clicked.
When you look at the source code you will find the individual elements which make up the tree. Just modify the code in the onclick methods.
It would probably be a good idea to just copy the entire source code over to another file and call it something else (like mytree, or whatever).
jstretch
01-18-2006, 04:30 AM
I found the following in tree.lzx. Do you know how I can make a seperate onclick event for the text?
<view name="icon">
<method event="onclick">
classroot.toggleOpenAndFocus()
if (classroot.onclick) classroot.onclick.sendEvent();
</method>
<method event="ondblclick">
<![CDATA[
if (classroot.onactivate) {
classroot.onactivate.sendEvent();
}
]]>
</method>
<view name="icon"
resource="$once{classroot.icon}"
frame="${classroot.isleaf ? 3
:(classroot.open ? 2 : 1)}" />
</view>
<text name="text" text="${classroot.text}" resize="true"
bgcolor="${classroot.selected
? classroot.style['selectedcolor']
: (classroot.focused
? classroot.style['hilitecolor']
: classroot.parent.bgcolor ) }">
<method event="onclick">
classroot.toggleOpenAndFocus()
if (classroot.onclick) classroot.onclick.sendEvent();
</method>
<method event="ondblclick">
<![CDATA[
if (classroot.onactivate) {
classroot.onactivate.sendEvent();
}
]]>
</method>
</text>
jstretch
01-18-2006, 04:33 AM
Would something like this be the right approach?
<tree text="click me instead">
<method event="onclicktext">
</method>
</tree>
jstretch
01-18-2006, 05:01 AM
Ok I figured out one way to go about it, thanks for the help! I just commened what was already there and made a call to a method I defined in the actual tree. Easier than I thought.
<method event="onclick">
parent.parent.doSomethingElse();
//classroot.toggleOpenAndFocus()
//if (classroot.onclick) classroot.onclick.sendEvent();
</method>
</text>
vBulletin® v3.8.4, Copyright ©2000-2012, Jelsoft Enterprises Ltd.