简体   繁体   English

如何将点击事件添加到GXT FramedPanel的标题中

[英]How to add a click event to the header of the GXT FramedPanel

Is there a standard or easy way to add a click event/ handler to the header of the GXT FramedPanel? 是否有标准或简单的方法可以将click事件/处理程序添加到GXT FramedPanel的标题中?

I want to forward the click event to the expand/ collapse method of the FramedPanel, so the user has not to click explicitly on the small button of the header but rather can use the whole header. 我想将click事件转发到FramedPanel的expand / collapse方法,因此用户不必显式单击标题的小按钮,而是可以使用整个标题。

Thank you :) 谢谢 :)

I've solved the problem like that: 我已经解决了这样的问题:

import com.google.gwt.user.client.Event;

FramedPanel randomFramedPanel = ...;
XElement headerElement = randomFramedPanel.getHeader().getElement();
Event.sinkEvents(headerElement, Event.ONCLICK);
Event.setEventListener(headerElement, new EventListener() {
    @Override
    public void onBrowserEvent(com.google.gwt.user.client.Event event) {
        if (Event.ONCLICK == event.getTypeInt()) {
            // Do something...
        }
    }
});

Remember that the panel has to be attached to the dom to sink events, so eventually you have to check that, too. 请记住,必须将面板附加到dom上才能下沉事件,因此最终您也必须进行检查。

If you know a smarter solution, let me know :) 如果您知道更聪明的解决方案,请告诉我:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM