HandlerRegistration的gwt问题 [英] gwt problem with HandlerRegistration

查看:157
本文介绍了HandlerRegistration的gwt问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题。
我有一张地图并添加了ClickHandler,但按下按钮后,我想将其删除。我知道有一些HandlerRegistration,但我不知道如何使用它。
部分代码:

  map.addMapClickHandler(new MapClickHandler()

{
public void onClick(MapClickEvent e)
{
...
}
});

任何人都可以帮助我吗?

解决方案

如果您仍然需要这个,我花了一段时间才能找出解决方案。

  final Set< HandlerRegistration> hack = new HashSet< HandlerRegistration>(); 
hack.add(map.addMapClickHandler(new MapClickHandler(){
public void onClick(MapClickEvent e){
...
//在此删除处理程序
for (HandlerRegistration hr:hack){
hr.removeHandler();
}
}
}));


I have a problem. I have a map and added ClickHandler, but after pushing a button I want to remove it. I know that there's some HandlerRegistration but I don't know how to use it. part of my code:

map.addMapClickHandler(new MapClickHandler()

        {
            public void onClick(MapClickEvent e) 
            {
                 ...
                }
        });

can anyone help me?

解决方案

In case you still need this, it took me a while to figure out the solution

final Set<HandlerRegistration> hack = new HashSet<HandlerRegistration>();
hack.add(map.addMapClickHandler(new MapClickHandler() {
    public void onClick(MapClickEvent e) {
        ...
        // remove handler here
        for (HandlerRegistration hr : hack) {
            hr.removeHandler();
        }
    }
}));

这篇关于HandlerRegistration的gwt问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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