1

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

Robert Childan
  • 983
  • 1
  • 12
  • 22
  • 1
    put a "protection screen" on? i.e. a transparent container on top which blocks interaction. just my 2cents. – jldupont Jan 14 '10 at 02:08

2 Answers2

5

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();
                    }
                }
            });
David Nouls
  • 1,895
  • 12
  • 21
  • In GWT 1.x there was something similar available (but I forget the exact class/method/listener, 2.0 is really much better) – David Nouls Jan 14 '10 at 09:02
  • I am using GWT 2.0, this is close to what I want, but not the exactly. Is there a way I can intercept for instance, Event.ONCLICK and disable all other listeners – Robert Childan Jan 17 '10 at 02:47
  • Well, you can get access to the actual event with
    pEvent.getNativeEvent();
    
    and on that object you can get the type and see if it is an ClickEvent Type.
    – David Nouls Jan 18 '10 at 09:11
1

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.

ciczan
  • 340
  • 2
  • 8