asked
2013-03-22 16:59:27 +0800
kbsimm 153
http://www.ArivX.com/
How does one cause an item matching typed in characters of a combobox to scroll into view?
Details:
In relation to an earlier question I asked, AutoCompleteComboBox..., I am attempting to use a Combobox and ListModelList as follows:
- The user will type one or more characters into the Combobox.
- The Combobox will perform what is typically known as type ahead or autocomplete.
- The matching value will be displayed in the Combobox's textbox.
- The Combobox's list will scroll to the matching value.
1 thru 3 work fine but 4 does not. That is the Combobox does not scroll to the matching item.
I would expect the scrolling to be on the Combobox but looking at javadocs ListModelList has a fireSelectionEvent which speaks of the ability to scroll into view. Or rather it speaks of the default which is not to scroll into view and provides no convenient method to change that. I find it odd that scrolling is on the model not the UI element, Combobox.
I have found the static Client.scrollIntoView(Component cmp) which I attempted as
Combobox c = new Combobox();
c.setModel(customers);
c.addEventListener(Events.ON_CHANGING, new EventListener<InputEvent>(){
@Override
public void onEvent(InputEvent event) throws Exception {
Clients.scrollIntoView(c.getSelectedItem());
}
});
But that does not work.
Help is appreciated. Thank you