From f58438058b1a0b0d5266c8ca6acafcbbfda27ed4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 5 Nov 2010 21:42:49 +0000 Subject: [PATCH] Show the first, not the last, inserted item in wxListBox in wxOSX. The listbox showed its last, not first, item after creation in wxOSX which was inconsistent with the other ports and generally inconvenient. Fix this by ensuring that the first item being inserted is shown, and not the last one as was (implicitly) the case before. A better fix would be to avoid scrolling entirely but I don't know how to do this with NSClipView. Closes #12365. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66038 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/listbox_osx.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/osx/listbox_osx.cpp b/src/osx/listbox_osx.cpp index e7194b1b99..c8a037b899 100644 --- a/src/osx/listbox_osx.cpp +++ b/src/osx/listbox_osx.cpp @@ -357,6 +357,14 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items, GetListPeer()->UpdateLineToEnd(startpos); + // Inserting the items may scroll the listbox down to show the last + // selected one but we don't want to do it as it could result in e.g. the + // first items of a listbox be hidden immediately after its creation so + // show the first selected item instead. Ideal would probably be to + // preserve the old selection unchanged, in fact, but I don't know how to + // get the first visible item so for now do at least this. + SetFirstItem(startpos); + UpdateOldSelections(); return idx; -- 2.45.2