From 494c9c9b0b1aecb0430678ea37cfb169da3c6ae8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 22 May 2014 14:36:00 +0000 Subject: [PATCH] Avoid showing the colour selection dialog twice in wxPropertyGrid. Selecting "Custom" in a colour property cell resulted in the colour selection dialog being shown twice if it was cancelled the first time. Fix this by using wxPG_PROPERTY_SPECIFIC to indicate that the value is just being queried and the user shouldn't be asked to enter it, as it is already in the other places. Closes #15543. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@76597 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/propgrid/advprops.cpp | 23 ++++++++++++++++++++--- src/propgrid/editors.cpp | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/propgrid/advprops.cpp b/src/propgrid/advprops.cpp index e4eef91713..e7d4d8e083 100644 --- a/src/propgrid/advprops.cpp +++ b/src/propgrid/advprops.cpp @@ -1262,14 +1262,20 @@ bool wxSystemColourProperty::QueryColourFromUser( wxVariant& variant ) const } -bool wxSystemColourProperty::IntToValue( wxVariant& variant, int number, int WXUNUSED(argFlags) ) const +bool wxSystemColourProperty::IntToValue( wxVariant& variant, int number, int argFlags ) const { int index = number; int type = m_choices.GetValue(index); if ( type == wxPG_COLOUR_CUSTOM ) { - QueryColourFromUser(variant); + if ( !(argFlags & wxPG_PROPERTY_SPECIFIC) ) + return QueryColourFromUser(variant); + + // Call from event handler. + // User will be asked for custom color later on in OnEvent(). + wxColourPropertyValue val = GetVal(); + variant = DoTranslateVal(val); } else { @@ -1448,7 +1454,18 @@ bool wxSystemColourProperty::StringToValue( wxVariant& value, const wxString& te return false; } - QueryColourFromUser(value); + if ( (argFlags & wxPG_PROPERTY_SPECIFIC) ) + { + // Query for value from the event handler. + // User will be asked for custom color later on in OnEvent(). + ResetNextIndex(); + return false; + } + if ( !QueryColourFromUser(value) ) + { + ResetNextIndex(); + return false; + } } else { diff --git a/src/propgrid/editors.cpp b/src/propgrid/editors.cpp index eeb467b366..f9908ffb1a 100644 --- a/src/propgrid/editors.cpp +++ b/src/propgrid/editors.cpp @@ -1277,7 +1277,7 @@ bool wxPGComboBoxEditor::GetValueFromControl( wxVariant& variant, wxPGProperty* return true; } - bool res = property->StringToValue(variant, textVal, wxPG_EDITABLE_VALUE); + bool res = property->StringToValue(variant, textVal, wxPG_EDITABLE_VALUE|wxPG_PROPERTY_SPECIFIC); // Changing unspecified always causes event (returning // true here should be enough to trigger it).