From f51cb52004d0d72fe253712867363163b0f2faaf Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Jun 2018 23:17:03 +0200 Subject: [PATCH] Reformat comments and code in MacHandleSelectionChange() No real changes, just trying to make the code more clear. --- src/osx/listbox_osx.cpp | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/osx/listbox_osx.cpp b/src/osx/listbox_osx.cpp index 51cd293ca6..01b6ef7f0d 100644 --- a/src/osx/listbox_osx.cpp +++ b/src/osx/listbox_osx.cpp @@ -425,17 +425,21 @@ void wxListBox::MacHandleSelectionChange(int row) if ( m_blockEvents ) return; - // Correct notification events for multiselection list, like in Carbon version + // Correct notification events for multiselection list. if ( HasMultipleSelection() ) { CalcAndSendEvent(); return; } - // OS X can select an item below the last item. In that case keep the old selection because - // in wxWidgets API there is no notification event for removing the selection from a single-selection list box. - // Otherwise call DoChangeSingleSelection so GetOldSelection() will return the correct value if row < 0 later. - if ((row < 0) || (row > (int) GetCount())) + // OS X can select an item below the last item. In that case keep the old + // selection because in wxWidgets API there is no notification event for + // removing the selection from a single-selection list box. + // + // Otherwise call DoChangeSingleSelection so GetOldSelection() will return + // the correct value if row < 0 later. + const int count = static_cast(GetCount()); + if ( row < 0 || row > count ) { if ( !m_oldSelections.empty() ) { @@ -443,11 +447,11 @@ void wxListBox::MacHandleSelectionChange(int row) if (oldsel >= 0) SetSelection(oldsel); } - return; } - if ( !DoChangeSingleSelection(row) ) - return ; - HandleLineEvent( row, false ); + else if ( DoChangeSingleSelection(row) ) + { + HandleLineEvent( row, false ); + } } //