Disable user interaction in a GWT container?

2019-02-20 17:53发布

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)

there are more than one click handlers, and I don't want to bother with removing and adding listeners according to mode (interaction enabled/disabled)

Any ideas would be appriciated...

2条回答
对你真心纯属浪费
2楼-- · 2019-02-20 17:57

There is a GlassPanel compoent in google-web-toolkit-incubator. I am almost sure it does what you need. Either way, it is a good idea to cover a disabled component whit one of these.

查看更多
看我几分像从前
3楼-- · 2019-02-20 18: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();
                    }
                }
            });
查看更多
登录 后发表回答