sorry my bad, i got you an old version, forget about adding the listener and
use it that way.
public TreeNode(EntityTree entityTree){
super();
this.entityTree = entityTree;
HTML html = new HTML(entityTree.getName());
this.setWidget(html);
this.getElement().getStyle().setBackgroundImage("url("+entityTree.getIconUrl()+")");
this.getElement().getStyle().setPaddingLeft(20, Unit.PX);
this.setStyleName("treeNode");
this.getElement().setAttribute("oncontextmenu", "return false;");
this.sinkEvents(Event.MOUSEEVENTS);
}
@Override
public void onDetach(){
this.unsinkEvents(Event.MOUSEEVENTS);
super.onDetach();
}
@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if(DOM.eventGetType(event)==Event.ONMOUSEDOWN){
if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT){
TreeHandler.onRightClick(this);
}else if (DOM.eventGetButton(event) == Event.BUTTON_LEFT){
TreeHandler.onLeftClick(this);
}
}else if(DOM.eventGetType(event)==Event.ONMOUSEOVER){
TreeHandler.onMouseOver(this);
}else if(DOM.eventGetType(event)==Event.ONMOUSEOUT){
TreeHandler.onMouseOut(this);
}
}
On Thu, Jul 1, 2010 at 7:50 PM, rudolf michael <[email protected]> wrote:
> well you dont event need to override the onBrowserEvent method :)
> MyTreeImages treeimages = GWT.create(MyTreeImages.class);
> Tree tree = new Tree(treeimages);
> //tree.addOpenHandler(handler);
> tree.setAnimationEnabled(true);
> TreeNode node = new TreeNode(result.get(i));
> node.addClickHandler(SMDesigner_gwt.handler);
> TreeItem item = new TreeItem(node);
> node.setItemTree(item);
> item.addItem("loading...");
> tree.addItem(item);
> treePanel.add(tree);
>
> MyTreeImages is an interface that override the tree images, it contains the
> following:
> @Override
> @Source("space.png")
> public ImageResource treeClosed();
>
> @Override
> @Source("space.png")
> public ImageResource treeLeaf();
>
> @Override
> @Source("space.png")
> public ImageResource treeOpen();
> where space is 1x1 pixel image.
> and TreeNode constructor has the a POJO class as param to pass the name and
> image fetched from db
> public TreeNode(EntityTree entityTree){
> super();
> this.entityTree = entityTree;
> HTML html = new HTML(entityTree.getName());
> this.setWidget(html);
>
> this.getElement().getStyle().setBackgroundImage("url("+entityTree.getIconUrl()+")");
> this.getElement().getStyle().setPaddingLeft(20, Unit.PX);
> this.setStyleName("treeNode");
> }
> hope that it is clear enough to get the idea.
>
> regards,
> Rudolf Michael
>
> On Thu, Jul 1, 2010 at 7:25 PM, Yaakov <[email protected]> wrote:
>
>> How do you accomplish the "hit test", if you don't mind sharing that
>> part.
>>
>> Thanks,
>> Yaakov.
>>
>> On Jul 1, 11:52 am, Jim Douglas <[email protected]> wrote:
>> > I listen for the right-click event on the Tree, then do a hit test of
>> > the point to identify the corresponding TreeItem. And don't forget to
>> > call preventDefault() on the event to suppress the browser's default
>> > context menu. (That last part works in Opera 10.5x, but Opera 10.10
>> > ignores it and puts up the context menu anyway.)
>> >
>> > On Jul 1, 8:24 am, Yaakov <[email protected]> wrote:
>> >
>> > > Well, TreeItem does not inherit from a Widget, so it doesn't have
>> > > onBrowserEvent to override. So, how would you do that then?
>> >
>> > > Thanks,
>> > > Yaakov.
>> >
>> > > On Jul 1, 3:20 am, rudolf michael <[email protected]> wrote:
>> >
>> > > > hello,
>> > > > you need to override the default behavior of the browser event on
>> the
>> > > > treeitem
>> > > > @Override
>> > > > public void onBrowserEvent(Event event) {
>> > > > super.onBrowserEvent(event);
>> > > > if(DOM.eventGetType(event)==Event.ONMOUSEDOWN){
>> > > > if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT){
>> > > > TreeHandler.onRightClick(this);
>> > > > }else if (DOM.eventGetButton(event) ==
>> Event.BUTTON_LEFT){
>> > > > TreeHandler.onLeftClick(this);
>> > > > }}else if(DOM.eventGetType(event)==Event.ONMOUSEOVER){
>> >
>> > > > TreeHandler.onMouseOver(this);}else
>> if(DOM.eventGetType(event)==Event.ONMOUSEOUT){
>> >
>> > > > TreeHandler.onMouseOut(this);
>> >
>> > > > }
>> > > > }
>> >
>> > > > On Thu, Jul 1, 2010 at 8:19 AM, ganesh.shirsat <
>> [email protected]>wrote:
>> >
>> > > > > hi,
>> >
>> > > > > How to get TreeItem on right click in GWT 2.0.3
>> >
>> > > > > please help me
>> >
>> > > > > thanks,
>> > > > > Ganesh Shirsat
>> >
>> > > > > --
>> > > > > You received this message because you are subscribed to the Google
>> Groups
>> > > > > "Google Web Toolkit" group.
>> > > > > To post to this group, send email to
>> [email protected].
>> > > > > To unsubscribe from this group, send email to
>> > > > > [email protected]<google-web-toolkit%[email protected]><google-web-toolkit%2Bunsubs
>> [email protected]>
>> > > > > .
>> > > > > For more options, visit this group at
>> > > > >http://groups.google.com/group/google-web-toolkit?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Web Toolkit" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<google-web-toolkit%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-web-toolkit?hl=en.
>>
>>
>
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.