Vaadin 7 ClickListener for non-button elements

Hi,

I am not able to add a click listener on any other component than a button.
I tried the following:

	VerticalLayout myElement = new VerticalLayout();
	myElement.setIcon(new ThemeResource("img/50_50.png"));
	myElement.setImmediate(true);
	myElement.setWidth("-1px");
	myElement.setHeight("-1px");
	myElement.setMargin(true);
	myElement.setSpacing(true);
	parentLayout.addComponent(myElement);
	parentLayout.setComponentAlignment(myElement, new Alignment(48));

    myElement.addLayoutClickListener(new LayoutClickListener() {
        
        @Override
        public void layoutClick(LayoutClickEvent event) {
			...
		}
	});

But the code inside the “layoutClick” never get reached…
Any tips are welcome.

Regards
Lukas

Hi,

LayoutClickListener should work OK, as you can try
here
.

Your code doesn’t have anything inside the layout… I’m not immediately sure what size a VerticalLayout with undefined size would have, but without any containing components, probably zero size. So what are you clicking? You at least need to make it have a defined size, or if undefined, have some components inside it to give it some size.