]> git.saurik.com Git - wxWidgets.git/commitdiff
added checks for the item index
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 13 Jun 2003 12:42:35 +0000 (12:42 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 13 Jun 2003 12:42:35 +0000 (12:42 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21104 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/vlbox.cpp

index e15de81c6a40a8b7284bc25b12ee8987ff711f92..2f6276cd814087b23f721994eab3925c9b1ab9ee 100644 (file)
@@ -188,6 +188,10 @@ bool wxVListBox::DoSelectAll(bool select)
 
 bool wxVListBox::DoSetCurrent(int current)
 {
+    wxASSERT_MSG( current == wxNOT_FOUND ||
+                    (current >= 0 && (size_t)current < GetItemCount()),
+                  _T("wxVListBox::DoSetCurrent(): invalid item index") );
+
     if ( current == m_current )
     {
         // nothing to do
@@ -239,6 +243,10 @@ void wxVListBox::SendSelectedEvent()
 
 void wxVListBox::SetSelection(int selection)
 {
+    wxCHECK_RET( selection == wxNOT_FOUND ||
+                  (selection >= 0 && (size_t)selection < GetItemCount()),
+                  _T("wxVListBox::SetSelection(): invalid item index") );
+
     wxASSERT_MSG( !HasMultipleSelection(),
                   _T("SetSelection() is invalid with multiselection listbox") );
 
@@ -502,13 +510,18 @@ void wxVListBox::OnLeftDown(wxMouseEvent& event)
 {
     int item = HitTest(event.GetPosition());
 
-    DoHandleItemClick(item, event.ShiftDown(),
+    if ( item != wxNOT_FOUND )
+    {
+        // under Mac Apple-click is used in the same way as Ctrl-click
+        // elsewhere
+        DoHandleItemClick(item, event.ShiftDown(),
 #ifdef __WXMAC__
-                            event.MetaDown()
+                                event.MetaDown()
 #else
-                            event.ControlDown()
+                                event.ControlDown()
 #endif
-                     );
+                         );
+    }
 }
 
 void wxVListBox::OnLeftDClick(wxMouseEvent& event)