Qri
Qri

Reputation: 237

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?

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.

Thank you :)

Upvotes: 2

Views: 343

Answers (1)

Qri
Qri

Reputation: 237

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.

If you know a smarter solution, let me know :)

Upvotes: 3

Related Questions