user1068477
user1068477

Reputation:

Vaadin How to SelectAll() in ComboBox field?

Vaadin 7.6.2

What's the best approach to performing a selectAll() in ComboBox field?

Upvotes: 0

Views: 322

Answers (1)

Henri Kerola
Henri Kerola

Reputation: 4967

If you mean selecting all text in the input field of a ComboBox, there is no a build-in support for that.

The most elegant solution would be to create your own Vaadin extension, which would provide server-side API for selecting text in a ComboBox.

The easiest but a bit hackish solution is to defined a unique id for your ComboBox:

comboBox.setId("my-combobox");

and use the JavaScript API of Vaadin to execute a JavaScript snippet that selects text on client side:

JavaScript.eval("setTimeout(function() { document.getElementById('my-combobox').firstChild.select(); }, 0);");

I tested this quickly, and it seemed to work in Chrome, Safari and Firefox at least.

Upvotes: 2

Related Questions