Open GoogleCodeExporter opened 9 years ago
For now, if you really need this you can add a click handler to the iconHTML
(or add it programmatically via the low-level GWT Element API).
Original comment by smartgwt...@gmail.com
on 13 Sep 2012 at 10:35
Trying to understand, I fixed so (using the eventproxy, because the GWT
Element has no methods to add an handler, only the gwt.Widget has
addAttachHandler):
350: protected void showSample(TreeNode node) {
351: boolean isExplorerTreeNode = node instanceof ExplorerTreeNode;
352: if (node instanceof CommandTreeNode) {
....
.... unchanged code ....
....
374: String icon = explorerTreeNode.getIcon();
375: if (icon == null) {
376: icon = "silk/plugin.png";
377: }
//create a foo Img to have an eventproxy attached
378: Img img0 = new Img(icon, 16, 16);
379: img0.setVisible(false);
380: img0.addClickHandler(new
com.smartgwt.client.widgets.events.ClickHandler() {
381: @Override
382: public void onClick(ClickEvent event) {
383: SC.say("it work");
384: }
385: });
//temporary attach the image to mainTabSet to have the DOM element rendered
386: mainTabSet.addChild(img0);
//retrieve the img0's eventproxy and attach it to the <img .. > tag
387: com.google.gwt.dom.client.Element img0El =
img0.getDOM();
388: String eventProxy = img0El.getAttribute("eventproxy");
389: String imgHTML = img0El.getInnerHTML();
390: imgHTML = imgHTML.replaceAll(">", "eventProxy=\""
+eventProxy+ "\">" );
//finally set the title
391: tab.setTitle("<span>" + imgHTML + " " + sampleName +
"</span>");
392: tab.setPane(panel);
393: tab.setCanClose(true);
//remove the foo img as it isn't necessary (the eventproxy has created) (it is dangerous: the garbage collector could reuse eventproxy for other handler)
394: mainTabSet.removeChild(img0);
395:
396: mainTabSet.addTab(tab);
397: mainTabSet.selectTab(tab);
398: } else {
399: mainTabSet.selectTab(tab);
400: }
401: }
402: }
403: }
Original comment by antonucc...@gmail.com
on 16 Sep 2012 at 9:35
Original issue reported on code.google.com by
antonucc...@gmail.com
on 13 Sep 2012 at 8:57Attachments: