Make HorizontalLayout focusable


Component.Focusable interface able some component to be focusable (Panel, NativeButton, NativeSelect, OptionGroup, Panel …).
Is this possible to make an HorizontalLayout focusable ?

Thanks in advance.


What would be the point of that?

My website contain an help icon with a button listener and when i click on it, i want to focus on the HorizontalLayout which is on bottom of the page.

Why don’t you just focus on some component inside the HorizontalLayout?

I have an icon (Embedded) and a text (Label) in the HorizontalLayout, it’s not possible to focus on that (Embedded or Label).

Neither icon nor label can received any keyboard events → neither is focusable. (Focus is only relevant for keyboard events)

Are we getting confused upon what you mean by focus?

Actually I use a Panel instead of
can implement
interface. And i want to do something like that with the

Instead of a Button, trying using a Link for the icon. Something like this:

Link help = new Link()
help.setIcon(new ThemeResource("icons/32/help.png"));
help.setResource(new ExternalResource("#help");

Then, in your HorizontalLayout, create a named anchor:

Label helpAnchor = new Label("<a name='help' />", Label.CONTENT_XHTML);

Finally, define some CSS so that the anchor doesn’t take up any space:

.v-label-help-anchor {
  width: 0;
  height: 0;

Note that I haven’t actually tried this out! Conceptually, however, it should work (provided you don’t have a UriFragmentHandler that messes this up). Please let me know if it does. :slight_smile:

It works perfectly :lol: witout UriFragmentHandler problem !

Thanks a lot !!