单元格的有效 GWT DOM/消耗事件的列表是什么?
我已经多次遇到过这个问题,但找不到任何全面的内容。我想知道 GWT 所有有效的可消耗 DOM 事件的完整列表。
NativeEvent 的 GWT 文档 说:
public final java.lang.String getType()
Gets the enumerated type of this event.
Returns:
the event's enumerated type
此枚举在哪里?它真的存在吗?实际使用的代码(我发现)明确表示这些事件总是使用字符串:“click”、“contextmenu”、“mouseup”、“dblclick”等(等等涵盖了很多模糊之处......)
我'我正在尝试对 CellTable 中的单元格实现双击和右键单击 这篇文章。我正在传递 super("click", "contextmenu", "mouseup", "dblclick");在我的 AbstractCell 扩展的构造函数中。然后我重写了 onBrowserEvent:
@Override
public void onBrowserEvent(Context context, Element parent, ImageProperties<T> value,
NativeEvent event, ValueUpdater<ImageProperties<T>> valueUpdater) {
if (event.getButton() == NativeEvent.BUTTON_RIGHT) {
event.stopPropagation();
event.preventDefault();
eventBus.fireEvent(new RightClickEvent<Context>(context, event));
} else {
super.onBrowserEvent(context, parent, value, event, valueUpdater);
}
}
但是,我遇到了两个问题。第一,默认的 contextMenu 仍然会显示(在我的自定义菜单之上)——更不用说它甚至不使用 DOM 事件类型。另一个问题,如何检查它是否是双击事件?我发现很难相信它实际上是一组任意的字符串......
提前致谢! 约翰
I've run into this multiple times, and can't find anything comprehensive. I want to know the complete list of all valid consumable DOM events for GWT.
The GWT docs for NativeEvent says:
public final java.lang.String getType()
Gets the enumerated type of this event.
Returns:
the event's enumerated type
Where is this enumeration? Does it actually exist? The actual code used (that I've found) that explicitly says these events always uses strings: "click", "contextmenu", "mouseup", "dblclick", etc. (etc covers so many vaguaries ...)
I'm trying to implement both Double Click and Right Click for cells in a CellTable ala this post. I'm passing super("click", "contextmenu", "mouseup", "dblclick"); in the constructor of my extension of AbstractCell. Then I overrode onBrowserEvent:
@Override
public void onBrowserEvent(Context context, Element parent, ImageProperties<T> value,
NativeEvent event, ValueUpdater<ImageProperties<T>> valueUpdater) {
if (event.getButton() == NativeEvent.BUTTON_RIGHT) {
event.stopPropagation();
event.preventDefault();
eventBus.fireEvent(new RightClickEvent<Context>(context, event));
} else {
super.onBrowserEvent(context, parent, value, event, valueUpdater);
}
}
However, I run into two issues. One, the default contextMenu still gets shown (over my custom one) - not to mention it doesn't even use the DOM event type. A different problem, how do I check if its a double click event? I find it hard to believe that it's literally an arbitrary set of strings ...
Thanks in advance!
John
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
原生 JavaScript DOM 事件类型确实是任意字符串并支持给定的事件类型(以及其名称)可以依赖于浏览器。
Native JavaScript DOM event types really are arbitrary strings and support for a given event type (and the name thereof) can be browser dependent.
您要查找的枚举确实存在在BrowserEvents 类。您应该使用这些常量而不是“魔术”字符串文字。
the enumeration you are looking for does exist in the BrowserEvents class. you should use those constants instead of “magic” string literals.