GWT capturing drag & drop events

梦想的初衷 提交于 2019-12-24 03:05:17

问题


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?

Thanks


回答1:


Try using RootPanel.get() instead of RootLayoutPanel.get().

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).



来源:https://stackoverflow.com/questions/12900945/gwt-capturing-drag-drop-events

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