diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index baaccbd974..f0f9fa1725 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -2134,10 +2134,10 @@ long wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) switch ( nMsg ) { case WM_RBUTTONDOWN: - // if the item we are about to right click on - // is not already select, remove the entire - // previous selection - if (!::IsItemSelected(GetHwnd(), htItem)) + // if the item we are about to right click on is not already + // selected or if we click outside of any item, remove the + // entire previous selection + if ( !htItem || !::IsItemSelected(GetHwnd(), htItem) ) { UnselectAll(); }