wxListBox remote scrolling - selected item not visible

Hello,

we are using wxTextCtrl and wxListBox in conjunction to form a
word wheel. The purpose is to display a list of matching items
in the list box when typing something into the (single-line)
wxTextCtrl. Everything works nicely except for the following:

When the user hits up-arrow/down-arrow the wxTextCtrl manually
moves the selection bar in the wxListbox by means of
SetSelection(). However, if the items extend beyond the bottom
of the listbox and the user keeps scrolling down the
then-selected items do not move into view as they do when the
wxListBox handles up-arrow/down-arrow events itself.

Is there any way we can remotely tell the (single-pick) wxListBox
to redisplay it's item list such that the currently selected
item is visible ? We have tried shunting the key events from
the text control to the list box by means of ProcessEvent()
or AddPendingEvent() without success.

Karsten

···

--
GPG key ID E4071346 @ wwwkeys.pgp.net
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

Howdy Karsten,

  Here's how I do this:

  First you need to know the 'selected' item's position. I use ItemData
as keys and thus do:

  pos = list.FindItemData ( -1, key )

  Next, get the height of the bounding rectangle:

  height = list.GetItemRect ( pos,
            code = wxLIST_RECT_BOUNDS)[1]

  Then 'scroll' to that position:

  list.ScrollList ( 0, height )

- Jim

···

On Thu, 2003-09-18 at 10:24, Karsten Hilbert wrote:

Hello,

we are using wxTextCtrl and wxListBox in conjunction to form a
word wheel. The purpose is to display a list of matching items
in the list box when typing something into the (single-line)
wxTextCtrl. Everything works nicely except for the following:

When the user hits up-arrow/down-arrow the wxTextCtrl manually
moves the selection bar in the wxListbox by means of
SetSelection(). However, if the items extend beyond the bottom
of the listbox and the user keeps scrolling down the
then-selected items do not move into view as they do when the
wxListBox handles up-arrow/down-arrow events itself.

Is there any way we can remotely tell the (single-pick) wxListBox
to redisplay it's item list such that the currently selected
item is visible ? We have tried shunting the key events from
the text control to the list box by means of ProcessEvent()
or AddPendingEvent() without success.

Karsten

Karsten Hilbert wrote:

Hello,

we are using wxTextCtrl and wxListBox in conjunction to form a
word wheel. The purpose is to display a list of matching items
in the list box when typing something into the (single-line)
wxTextCtrl. Everything works nicely except for the following:

When the user hits up-arrow/down-arrow the wxTextCtrl manually
moves the selection bar in the wxListbox by means of
SetSelection(). However, if the items extend beyond the bottom
of the listbox and the user keeps scrolling down the
then-selected items do not move into view as they do when the
wxListBox handles up-arrow/down-arrow events itself.

Is there any way we can remotely tell the (single-pick) wxListBox
to redisplay it's item list such that the currently selected
item is visible ?

SetFirstItem. It says it's Windows only but I think it works on the other platforms too.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!