禁用 GWT 容器中的用户交互? [英] Disable user interaction in a GWT container?

查看:19
本文介绍了禁用 GWT 容器中的用户交互?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想禁用/启用复合(flextable)中包含的许多小部件(如超链接、按钮等)上的用户交互(更具体地说是鼠标单击)

点击处理程序不止一个,我不想费心根据模式(交互启用/禁用)删除和添加侦听器

任何想法都会被采纳...

解决方案

您忘记提及 GWT 的版本.在 GWT 2.0 中,您可以使用此代码片段或类似内容.此功能允许您在将事件移交给目标小部件之前取消事件.

<前>Event.addNativePreviewHandler(new Event.NativePreviewHandler() {公共无效 onPreviewNativeEvent(NativePreviewEvent pEvent) {最终元素目标 = pEvent.getNativeEvent().getEventTarget().cast();//阻止所有针对组合子节点的事件.如果(DOM.isOrHasChild(getElement(),目标)){pEvent.cancel();}}});

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

解决方案

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();
                    }
                }
            });

这篇关于禁用 GWT 容器中的用户交互?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆