tags - How to handle Click event or any other Event in GWT Cloud? -
i using tagcloud_0.4.jar using tag cloud in gwt. now, when click on tag inside tag cloud, how can handle event or how can rpc call when user select tag cloud?
thanks.
here example catch clickevent on cloud. workaround library may change. developper not offer manage events on cloud neither on tags, perhaps reason...
so use code @ own risk. pray no change of widget's structure dom. suggest ask developper enhancements on widgets, managing such events.
final tagcloud cloud = new tagcloud(); cloud.addword(new wordtag("aaa")); cloud.addword(new wordtag("aaa")); cloud.addword(new wordtag("bbb")); cloud.addword(new wordtag("ccc")); cloud.addword(new wordtag("ccc")); cloud.addword(new wordtag("ccc")); cloud.adddomhandler(new clickhandler() { @override public void onclick(clickevent event) { // prevent click tag executed event.preventdefault(); element e; // each tag present in cloud, 1 triggered (int = 0; < cloud.gettags().size(); ++i) { // gets element in cloud, unsafe part of code // if developer change dom of widget e = dom.getchild(dom.getchild(cloud.getelement(), 0), i); // current element targeted event? if (event.getclientx() >= e.getoffsetleft() && event.getclienty() >= e.getoffsettop() && event.getclientx() <= e.getoffsetleft() + e.getoffsetwidth() && event.getclienty() <= e.getoffsettop() + e.getoffsetheight()) { // gets abstract tag tag t = cloud.gettags().get(i); // gets tag descendant if (t instanceof wordtag) { // want wordtag, maybe rpc call } else if (t instanceof imagetag) { // want imagetag, maybe rpc call } break; } } } }, clickevent.gettype());
Comments
Post a Comment