-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I'm trying to let my users use the up/down arrow keys to progress across a listbox' items without forcing them to use the mouse in order to select one list item as a start point. At first I noticed that it was indeed possible to reach a listbox by pressing tab in order to focus it; this would manifest as the whole listitem container being surrounded by the classical focus dotted line.
It was however impossible to proceed into the listitems themselves. I tried the following:
public void onFocus( Event pEvent ) { LOG.debug( "--> onFocus" ); if( getItemCount() != 0 ) { Listitem firstItem = getItemAtIndex( 0 ); firstItem.focus(); firstItem.setSelected( true ); } LOG.debug( "<-- onFocus" ); }
I inserted this method within my own listbox specialization, with no results. I think this is due to the fact that, according to the developer guide, listboxes do not accept 'onFocus' events.
So I wonder whether I should post this as a feature request or somebody out there has found some alternative way to obtain this effect.
With kind regards
César Varona
Hi César,
When I tried this myself it works:
1.tab focus into the listbox with grey dotted line.
2.press up and down key, then you are able to select the list items.
Please search "Mouseless Entry listbox" under dev guide.
Hi Robert,
I'm afraid I've been unable to experience that behaviour; this is what I've tried, both on ie7 and ff 2.0.0.18, with no results
1. I've opened the 'zk explorer' demo and selected the 'listboxes -> live data' menu option
2. I've modified the proposed source code like this:
<window title="Live Data" border="normal"> <zscript> String[] data = new String[30]; for(int j=0; j < data.length; ++j) { data = "option "+j; } ListModel strset = new SimpleListModel(data); </zscript> <b ><textbox /></b> <listbox id="list" width="200px" rows="10" model="${strset}"> <listhead> <listheader label="Load on Demend" sort="auto"/> </listhead> </listbox> </window>
I think I might be missing something at a very basic level. Are you able to step into listitem navigation without resorting to the mouse in the example above?
With kind regards
César Varona
Hi César,
This is a bug that needs to be fixed. Would you be able to post this to the Bugs list?
by the way, I tweaked your code:
<window title="Live Data" border="normal"> <zscript><![CDATA[ String[] data = new String[30]; for(int j=0; j < data.length; ++j) { data = "option "+j; } ListModel strset = new SimpleListModel(data); ]]></zscript> <textbox /> <listbox id="list" width="200px" rows="10" model="${strset}"> <listhead> <listheader label="Load on Demend" sort="auto"/> </listhead> <zscript> list.setSelectedItem(list.getItemAtIndex(0)); list.focus(); </zscript> </listbox> </window>
Regards,
Robert
Asked: 2008-11-12 10:22:08 +0800
Seen: 260 times
Last updated: Nov 26 '08