When handling browser events in a GWT CellTable, how do I get the most specific within a cell?

寵の児 提交于 2019-12-12 17:40:52

问题


The onBrowserEvent method of an abstract cell returns a parent element. If I have multiple HTML items rendered within the cell, such as spans or divs, how do I get and distinguish which one triggered the event?


回答1:


NativeEvent#getEventTarget() will give you the exact element that fired the event. You can then walk up until you find an element with some discriminant (e.g. a specific CSS class name), or walk down from the parent element and use Element#isOrHasChild().

Have a look at how CompositeCell dispatches the event to the appropriate cell,or how ButtonCell checks that you clicked the button inside the cell.



来源:https://stackoverflow.com/questions/7640372/when-handling-browser-events-in-a-gwt-celltable-how-do-i-get-the-most-specific

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!