I'd like to dynamically insert a Widget into/next to a single
TreeItem, whenever a TreeItem is selected, but event handlers on the
Widget never fire when I do this.
My approach so far: I dynamically manipulate the DOM of a single
TreeItem, when a selection event occurs. First I insert a DIV sibling,
and then I insert the Widget into that placeholder. Something like
this:
Button b = new Button("Click me", new ClickHandler() {
public void onClick(ClickEvent event) { Window.alert("I was
clicked!"); }
});
Element itemDiv = treeItem.getElement(); // the TreeItem's underlying
element
Element spanEdit = DOM.createSpan(); // a container, perhaps this
is not necessary
DOM.appendChild(itemDiv, spanEdit);
DOM.appendChild(spanEdit, b.getElement());
The button appears in the TreeItem when the TreeItem is selected, but
I am not able to generate any click events when I try to click on the
button with the mouse. I've also tried replacing the Button with
direct HTML, as follows:
HTML h = new HTML("<a href='javascript:alert();'>Click me for alert</
a>");
Once inserted into the TreeItem, on mouseover the browser status bar
shows the link target, but clicking on it does not generate a popup.
My sense is that I need to do something else when I insert an Element
into the DOM, to ensure that it participates in the event handling
correctly. Yes? What else do I need to do?
Perhaps the Tree's SelectionHandler is interfering - a mousedown on
anything within a tree's node triggers a selection event and no other
events are processed?
Note: This used to work for me, using GWT 1.4.62, but even then only
when the inserted Widget was a Button (for all other Widget's that I
tried, the click event never reached the declared handler).
Note: I would prefer to do all this without manipulating the DOM, but
there is a bug in TreeItem, since early version of GWT, that prohibits
me from dynamically removing and later replacing the TreeItem's
content.
http://code.google.com/p/google-web-toolkit/issues/detail?id=2297
Thanks for any help you can provide!
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---