GWT捕获拖曳下降事件

问题描述:

我正在尝试捕获拖放事件。现在我正在捕获添加一个dom处理程序到我的RootLayoutPanel的事件:

I'm trying to capture dragover and drop events. Right now I'm capturing those events adding a dom handler to my RootLayoutPanel:

dragOverHandler = RootLayoutPanel.get().addBitlessDomHandler(this, DragOverEvent.getType());
dropHandler = RootLayoutPanel.get().addBitlessDomHandler(this, DropEvent.getType());

问题是这个代码在显示弹出窗口时并没有捕获事件,拖放已经结束弹出窗口本身或其周围的玻璃。

The problem is this code does not capture the events when showing a popup and the drag/drop is over the popup itself or the glass around it.

我还尝试使用本机预览处理程序,但它似乎不会在拖放或拖放事件上调用:

I have also tried using a native preview handler, but it seems it is not called on dragover nor drop events:

Event.addNativePreviewHandler(new Event.NativePreviewHandler() {            
    @Override
    public void onPreviewNativeEvent(NativePreviewEvent event) {
        GWT.log(event.getNativeEvent().getType());  
    }
});

有没有一种直接的方式来捕获我应用程序中的所有拖放事件?

Is there a straight way to capture all dragover and drop events in my app?

谢谢

尝试使用 RootPanel.get() / code>而不是 RootLayoutPanel.get()

FYI, RootLayoutPanel.get() RootLayoutPanel 单例添加到 RootPanel.get()中; RootPanel.get()将文档的< body> 包含在 RootPanel ,所以它应该捕获所有东西(只要正文填充视口,这个 RootLayoutPanel 确保)。

FYI, RootLayoutPanel.get() adds the RootLayoutPanel singleton to the RootPanel.get(); RootPanel.get() wraps the document's <body> inside a RootPanel, so it should capture everything (provided the body fills the viewport, which the RootLayoutPanel ensures).