Making a layout clickable

Is there any supported (or hack-ish :)) way to make a whole layout clickable? I would like to attach a clicklistener to my CustomComponent.

I’d try making a ClickWrapper -component first, it’s so quick to test.

ServerSide:
layout.addComponent(new ClickWrapper(myCustomComponent, clickListener));

Component (pseudo):

public class ClickWrapper extends AbstractComponent {
  public ClickWrapper(Component c, ClickWrapper.ClickListener listener) {
    wrappedComponent = c;
  }
  public void paintContent(PaintTarget target) throws PaintException {
     super.paintContent(target);
     target.addVariable("click",false);
     wrappedComponent.paint(target);
  }
  public void changeVariables(map m) {
    if (m.containsKey("click")) {
     fireEvent();
    }
  }
}

Client:


public class IClickWrapper extends ComplexPanel implements IPaintable {
public IClickWrapper() {
        Element root = DOM.createElement("div");
        setElement(root);
        setStyleName("i-clickwrapper");
       DOM.sinkEvents(root, Event.MOUSEEVENTS);
    }

updateFromUidl(uidl, client) {
  UIDL childUidl = uidl.getChild(0);
   Paintable wrapped = client.getPaintable(childUidl);
   add((Widget)wrapped, getElement());
   wrapped.updateFromUIDL(childUidl, client);
}
public void onBrowserEvent) {
  if (DOM.eventGetType(event) == EVENT.ON_CLICK) {
  client.updateVariable(id, "click",true,true);
  }
}