Do not generate wxEVT_PG_SELECTED with direct ClearSelection() and SelectProperty() calls

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61644 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli 2009-08-11 16:53:05 +00:00
parent 90666795d4
commit 01b5ad3b50
7 changed files with 84 additions and 38 deletions

View File

@ -435,19 +435,21 @@ enum wxPG_KEYBOARD_ACTIONS
// wxPropertyGrid::DoSelectProperty flags (selFlags)
// Focuses to created editor
#define wxPG_SEL_FOCUS 0x01
#define wxPG_SEL_FOCUS 0x01
// Forces deletion and recreation of editor
#define wxPG_SEL_FORCE 0x02
#define wxPG_SEL_FORCE 0x02
// For example, doesn't cause EnsureVisible
#define wxPG_SEL_NONVISIBLE 0x04
#define wxPG_SEL_NONVISIBLE 0x04
// Do not validate editor's value before selecting
#define wxPG_SEL_NOVALIDATE 0x08
#define wxPG_SEL_NOVALIDATE 0x08
// Property being deselected is about to be deleted
#define wxPG_SEL_DELETING 0x10
#define wxPG_SEL_DELETING 0x10
// Property's values was set to unspecified by the user
#define wxPG_SEL_SETUNSPEC 0x20
#define wxPG_SEL_SETUNSPEC 0x20
// Property's event handler changed the value
#define wxPG_SEL_DIALOGVAL 0x40
#define wxPG_SEL_DIALOGVAL 0x40
// Set to disable sending of wxEVT_PG_SELECTED event
#define wxPG_SEL_DONT_SEND_EVENT 0x80
// -----------------------------------------------------------------------
@ -542,8 +544,11 @@ enum wxPG_KEYBOARD_ACTIONS
@beginEventTable{wxPropertyGridEvent}
@event{EVT_PG_SELECTED (id, func)}
Respond to wxEVT_PG_SELECTED event, generated when property value
has been changed by user.
Respond to wxEVT_PG_SELECTED event, generated when a property selection
has been changed, either by user action or by indirect program
function. For instance, collapsing a parent property programmatically
causes any selected child property to become unselected, and may
therefore cause this event to be generated.
@event{EVT_PG_CHANGING(id, func)}
Respond to wxEVT_PG_CHANGING event, generated when property value
is about to be changed by user. Use wxPropertyGridEvent::GetValue()
@ -935,19 +940,22 @@ public:
/**
Selects a property.
Editor widget is automatically created, but not focused unless focus is
true. This will generate wxEVT_PG_SELECT event.
true.
@param id
Property to select.
@return
True if selection finished successfully. Usually only fails if
current value in editor is not valid.
@remarks In wxPropertyGrid 1.4, this member function used to generate
wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
does that.
@see wxPropertyGrid::Unselect
*/
bool SelectProperty( wxPGPropArg id, bool focus = false )
{
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
return DoSelectProperty(p,focus?wxPG_SEL_FOCUS:0);
}
bool SelectProperty( wxPGPropArg id, bool focus = false );
/** Sets category caption background colour. */
void SetCaptionBackgroundColour(const wxColour& col);
@ -1779,7 +1787,11 @@ protected:
void CorrectEditorWidgetPosY();
/** Deselect current selection, if any. Returns true if success
(ie. validator did not intercept). */
(ie. validator did not intercept).
Unlike ClearSelection(), DoClearSelection() sends the
wxEVT_PG_SELECTED event.
*/
bool DoClearSelection();
int DoDrawItems( wxDC& dc,

View File

@ -210,8 +210,12 @@ public:
@return Returns @true if successful or if there was no selection. May
fail if validation was enabled and active editor had invalid
value.
@remarks In wxPropertyGrid 1.4, this member function used to send
wxPG_EVT_SELECTED. In wxWidgets 2.9 and later, it no longer
does that.
*/
bool ClearSelection( bool validation = false);
bool ClearSelection( bool validation = false );
/** Resets modified status of all properties.
*/

View File

@ -411,7 +411,12 @@ public:
/** Select and displays a given page. */
void SelectPage( wxPropertyGridPage* page );
/** Select a property. */
/**
Select a property.
@see wxPropertyGrid::SelectProperty(),
wxPropertyGridInterface::ClearSelection()
*/
bool SelectProperty( wxPGPropArg id, bool focus = false );
/**

View File

@ -320,8 +320,11 @@ typedef int (*wxPGSortCallback)(wxPropertyGrid* propGrid,
@beginEventEmissionTable{wxPropertyGridEvent}
@event{EVT_PG_SELECTED (id, func)}
Respond to wxEVT_PG_SELECTED event, generated when property value
has been changed by user.
Respond to wxEVT_PG_SELECTED event, generated when a property selection
has been changed, either by user action or by indirect program
function. For instance, collapsing a parent property programmatically
causes any selected child property to become unselected, and may
therefore cause this event to be generated.
@event{EVT_PG_CHANGING(id, func)}
Respond to wxEVT_PG_CHANGING event, generated when property value
is about to be changed by user. Use wxPropertyGridEvent::GetValue()
@ -707,8 +710,7 @@ public:
/**
Selects a property. Editor widget is automatically created, but
not focused unless focus is true. This will generate wxEVT_PG_SELECT
event.
not focused unless focus is true.
@param id
Property to select (name or pointer).
@ -719,7 +721,11 @@ public:
@return returns @true if selection finished successfully. Usually only
fails if current value in editor is not valid.
@see wxPropertyGrid::ClearSelection()
@remarks In wxPropertyGrid 1.4, this member function used to generate
wxEVT_PG_SELECTED. In wxWidgets 2.9 and later, it no longer
does that.
@see wxPropertyGridInterface::ClearSelection()
*/
bool SelectProperty( wxPGPropArg id, bool focus = false );

View File

@ -91,6 +91,12 @@ public:
@return Returns @true if successful or if there was no selection. May
fail if validation was enabled and active editor had invalid
value.
@remarks In wxPropertyGrid 1.4, this member function used to send
wxPG_EVT_SELECTED. In wxWidgets 2.9 and later, it no longer
does that.
@see wxPropertyGrid::SelectProperty()
*/
bool ClearSelection( bool validation = false);

View File

@ -849,7 +849,7 @@ void wxPropertyGrid::OnTLPChanging( wxWindow* newTLP )
void wxPropertyGrid::OnTLPClose( wxCloseEvent& event )
{
// ClearSelection forces value validation/commit.
if ( event.CanVeto() && !ClearSelection() )
if ( event.CanVeto() && !DoClearSelection() )
{
event.Veto();
return;
@ -1071,7 +1071,7 @@ void wxPropertyGrid::ResetColours()
bool wxPropertyGrid::SetFont( const wxFont& font )
{
// Must disable active editor.
ClearSelection(false);
DoClearSelection();
bool res = wxScrolledWindow::SetFont( font );
if ( res && GetParent()) // may not have been Create()ed yet
@ -2168,7 +2168,7 @@ void wxPropertyGrid::Clear()
bool wxPropertyGrid::EnableCategories( bool enable )
{
ClearSelection(false);
DoClearSelection();
if ( enable )
{
@ -2220,7 +2220,7 @@ void wxPropertyGrid::SwitchState( wxPropertyGridPageState* pNewState )
wxPGProperty* oldSelection = m_selected;
ClearSelection(false);
DoClearSelection();
m_pState->m_selected = oldSelection;
@ -3608,7 +3608,8 @@ bool wxPropertyGrid::DoSelectProperty( wxPGProperty* p, unsigned int flags )
m_inDoSelectProperty = 0;
// call wx event handler (here so that it also occurs on deselection)
SendEvent( wxEVT_PG_SELECTED, m_selected, NULL, flags );
if ( !(flags & wxPG_SEL_DONT_SEND_EVENT) )
SendEvent( wxEVT_PG_SELECTED, m_selected, NULL, flags );
return true;
}
@ -3661,11 +3662,23 @@ void wxPropertyGrid::RefreshEditor()
// -----------------------------------------------------------------------
// This method is not inline because it called dozens of times
// (i.e. two-arg function calls create smaller code size).
bool wxPropertyGrid::SelectProperty( wxPGPropArg id, bool focus )
{
wxPG_PROP_ARG_CALL_PROLOG_RETVAL(false)
int flags = wxPG_SEL_DONT_SEND_EVENT;
if ( focus )
flags |= wxPG_SEL_FOCUS;
return DoSelectProperty(p, flags);
}
// -----------------------------------------------------------------------
bool wxPropertyGrid::DoClearSelection()
{
return DoSelectProperty(NULL);
// Unlike ClearSelection(), here we send the wxEVT_PG_SELECTED event.
return DoSelectProperty(NULL, 0);
}
// -----------------------------------------------------------------------
@ -3679,7 +3692,7 @@ bool wxPropertyGrid::DoCollapse( wxPGProperty* p, bool sendEvents )
// If active editor was inside collapsed section, then disable it
if ( m_selected && m_selected->IsSomeParent(p) )
{
ClearSelection(false);
DoClearSelection();
}
// Store dont-center-splitter flag 'cause we need to temporarily set it
@ -3764,7 +3777,7 @@ bool wxPropertyGrid::DoHideProperty( wxPGProperty* p, bool hide, int flags )
( m_selected == p || m_selected->IsSomeParent(p) )
)
{
ClearSelection(false);
DoClearSelection();
}
m_pState->DoHideProperty(p, hide, flags);

View File

@ -220,7 +220,7 @@ wxPGProperty* wxPropertyGridInterface::ReplaceProperty( wxPGPropArg id, wxPGProp
bool wxPropertyGridInterface::ClearSelection( bool validation )
{
int flags = 0;
int flags = wxPG_SEL_DONT_SEND_EVENT;
if ( !validation )
flags |= wxPG_SEL_NOVALIDATE;
@ -297,7 +297,7 @@ bool wxPropertyGridInterface::ExpandAll( bool doExpand )
if ( GetSelection() && GetSelection() != state->DoGetRoot() &&
!doExpand )
{
pg->ClearSelection(false);
pg->DoClearSelection();
}
wxPGVIterator it;
@ -579,7 +579,7 @@ void wxPropertyGridInterface::Sort( int flags )
{
wxPropertyGrid* pg = GetPropertyGrid();
pg->ClearSelection(false);
pg->DoClearSelection();
unsigned int pageIndex = 0;
@ -1091,9 +1091,9 @@ bool wxPropertyGridInterface::RestoreEditableState( const wxString& src, int res
if ( pgSelectionSet )
{
if ( newSelection )
pg->SelectProperty(newSelection);
pg->DoSelectProperty(newSelection);
else
pg->ClearSelection();
pg->DoClearSelection();
}
if ( selectedPage != -1 )