在GWT CellTable中处理浏览器事件时,如何在单元格中获得最具体的内容? [英] When handling browser events in a GWT CellTable, how do I get the most specific within a cell?
问题描述
抽象单元格的onBrowserEvent方法返回一个父元素。
如果我在单元格中渲染了多个HTML项目,例如跨度或div,我该如何得到并区分哪一个触发事件?
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?
推荐答案
NativeEvent#getEventTarget()
将为您提供触发事件的确切元素。然后,您可以向上走,直到找到一些具有某种歧视(例如一个特定的CSS类名称)的元素,或者从父元素
元素中走下来,然后使用 元素#isOrHasChild()
。
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()
.
看看如何 CompositeCell
将事件调度到适当的单元格,或者如何 ButtonCell
检查您点击单元格内的按钮。
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.
这篇关于在GWT CellTable中处理浏览器事件时,如何在单元格中获得最具体的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!