Disable user interaction in a GWT container?

后端 未结 2 424
谎友^
谎友^ 2021-01-16 06:31

I want to disable/enable user interaction (mouse click more specificly) on many widgets like hyperlink, button, etc which are contained in a composite (flextable)

th

2条回答
  •  野的像风
    2021-01-16 07:10

    You forgot to mention the version of GWT. In GWT 2.0 you can use this code snippet or something similar. This feature allows you to cancel events before they are handed over to the target widget.

    Event.addNativePreviewHandler(new Event.NativePreviewHandler() {
                    public void onPreviewNativeEvent(NativePreviewEvent pEvent) {
                        final Element target = pEvent.getNativeEvent().getEventTarget().cast();
    
                        // block all events targetted at the children of the composite.
                        if (DOM.isOrHasChild(getElement(), target)) {
                            pEvent.cancel();
                        }
                    }
                });
    

提交回复
热议问题