From 39b9a6bbeb1aaff25621b7bbbeaf678bc3974819 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 1 Jun 2015 00:40:26 +0200 Subject: [PATCH] Don't generate bogus root item selection events in wxMSW wxTreeCtrl. Setting focus to the control when receiving a selection event can result in another selection event being generated by the control itself if it hadn't had any selection before, which is completely artificial, i.e. doesn't correspond to any user action, and so has to be suppressed. Closes #16999. --- docs/changes.txt | 1 + src/msw/treectrl.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/docs/changes.txt b/docs/changes.txt index 1d55b3df2d..690b17f601 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -157,6 +157,7 @@ wxMSW: - Fix unexpected change in MDI children order after showing a file dialog. - Don't send events for already selected radio popup menu items (Kinaou Hervé). - wxListCtrl::GetItemCount() in wxEVT_LIST_INSERT_ITEM is no longer off by 1. +- Don't send bogus root selection events when clicking wxTreeCtrl (sbrowne). wxOSX/Cocoa: diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 038293121e..b6f9789aad 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -3477,7 +3477,14 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) // to avoid such surprises, we force the generation of focus events // now, before we generate the selection change ones if ( !m_changingSelection && !m_isBeingDeleted ) + { + // Setting focus can generate selection events too however, + // suppress them as they're completely artificial and we'll + // generate the real ones soon. + TempSetter set(m_changingSelection); + SetFocus(); + } break; // instead of explicitly checking for _WIN32_IE, check if the