Focus on CssLayout

Hello guys,

How can I implement the focus method (Component.Focusable) on a CssLayout? This is what I’ve done so far:


public class FocusableLayout extends CssLayout implements Focusable {
	
	@Override
	public void focus() {
		getUI().setFocusedComponent((Focusable) this);
	}
	
	@Override
	public int getTabIndex() {
		return 0;
	}
	
	@Override
	public void setTabIndex(int tabIndex) {
		
	}
}

It isn’t much and of course it doesn’t work. I’ve looked at classes that does support the focus method (e.g. Button) but I’m not sure I understand what’s going on. Especially for the getTabIndex and setTabIndex methods.

My goal is for the browser to be able to show the entire (if possible) CssLayout once its focus method is called (e.g. when the user clicks on a Button or Link).

Thanks for your help.

Anybody?

If I remember correctly, enabling focusing a component requires that its client side widget implements com.vaadin.client.Focusable (or com.google.gwt.user.client.ui.Focusable). Implementing the server side interface com.vaadin.ui.Component.Focusable does not change how the client side behaves.

The client side method com.vaadin.client.Focusable can be implemented in various ways depending on the widget to focus and whether it extends FocusWidget or not.