Allow wxPGMultiButton to work even if primary editor control was not created in wxPGEditor::CreateControls(); Clarified related samples and documentation.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59450 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -534,6 +534,8 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    void DoAddButton( wxWindow* button, const wxSize& sz );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    int GenId( int id ) const;
 | 
					    int GenId( int id ) const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    wxArrayPtrVoid  m_buttons;
 | 
					    wxArrayPtrVoid  m_buttons;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -220,18 +220,19 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            if ( event.GetId() == buttons->GetButtonId(0) )
 | 
					            if ( event.GetId() == buttons->GetButtonId(0) )
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                // Do something when first button is pressed
 | 
					                // Do something when the first button is pressed
 | 
				
			||||||
                return true;
 | 
					                // Return true if the action modified the value in editor.
 | 
				
			||||||
 | 
					                ...
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if ( event.GetId() == buttons->GetButtonId(1) )
 | 
					            if ( event.GetId() == buttons->GetButtonId(1) )
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                // Do something when second button is pressed
 | 
					                // Do something when the second button is pressed
 | 
				
			||||||
                return true;
 | 
					                ...
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            if ( event.GetId() == buttons->GetButtonId(2) )
 | 
					            if ( event.GetId() == buttons->GetButtonId(2) )
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                // Do something when third button is pressed
 | 
					                // Do something when the third button is pressed
 | 
				
			||||||
                return true;
 | 
					                ...
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event);
 | 
					        return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -134,21 +134,21 @@ bool wxSampleMultiButtonEditor::OnEvent( wxPropertyGrid* propGrid,
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if ( event.GetId() == buttons->GetButtonId(0) )
 | 
					        if ( event.GetId() == buttons->GetButtonId(0) )
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // Do something when first button is pressed
 | 
					            // Do something when the first button is pressed
 | 
				
			||||||
            wxLogDebug("First button pressed");
 | 
					            wxLogDebug("First button pressed");
 | 
				
			||||||
            return true;
 | 
					            return false;  // Return false since value did not change
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if ( event.GetId() == buttons->GetButtonId(1) )
 | 
					        if ( event.GetId() == buttons->GetButtonId(1) )
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // Do something when second button is pressed
 | 
					            // Do something when the second button is pressed
 | 
				
			||||||
            wxLogDebug("Second button pressed");
 | 
					            wxMessageBox("Second button pressed");
 | 
				
			||||||
            return true;
 | 
					            return false;  // Return false since value did not change
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if ( event.GetId() == buttons->GetButtonId(2) )
 | 
					        if ( event.GetId() == buttons->GetButtonId(2) )
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // Do something when third button is pressed
 | 
					            // Do something when the third button is pressed
 | 
				
			||||||
            wxLogDebug("Third button pressed");
 | 
					            wxMessageBox("Third button pressed");
 | 
				
			||||||
            return true;
 | 
					            return false;  // Return false since value did not change
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event);
 | 
					    return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -2842,10 +2842,10 @@ void wxPropertyGrid::HandleCustomEditorEvent( wxEvent &event )
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    wxVariant pendingValue(selected->GetValueRef());
 | 
					    wxVariant pendingValue(selected->GetValueRef());
 | 
				
			||||||
    wxWindow* wnd = GetEditorControl();
 | 
					    wxWindow* wnd = GetEditorControl();
 | 
				
			||||||
 | 
					    wxWindow* editorWnd = wxDynamicCast(event.GetEventObject(), wxWindow);
 | 
				
			||||||
    int selFlags = 0;
 | 
					    int selFlags = 0;
 | 
				
			||||||
    bool wasUnspecified = selected->IsValueUnspecified();
 | 
					    bool wasUnspecified = selected->IsValueUnspecified();
 | 
				
			||||||
    int usesAutoUnspecified = selected->UsesAutoUnspecified();
 | 
					    int usesAutoUnspecified = selected->UsesAutoUnspecified();
 | 
				
			||||||
 | 
					 | 
				
			||||||
    bool valueIsPending = false;
 | 
					    bool valueIsPending = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    m_chgInfo_changedProperty = NULL;
 | 
					    m_chgInfo_changedProperty = NULL;
 | 
				
			||||||
@@ -2891,17 +2891,19 @@ void wxPropertyGrid::HandleCustomEditorEvent( wxEvent &event )
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    if ( !buttonWasHandled )
 | 
					    if ( !buttonWasHandled )
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        if ( wnd )
 | 
					        if ( wnd || m_wndEditor2 )
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            // First call editor class' event handler.
 | 
					            // First call editor class' event handler.
 | 
				
			||||||
            const wxPGEditor* editor = selected->GetEditorClass();
 | 
					            const wxPGEditor* editor = selected->GetEditorClass();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if ( editor->OnEvent( this, selected, wnd, event ) )
 | 
					            if ( editor->OnEvent( this, selected, editorWnd, event ) )
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                // If changes, validate them
 | 
					                // If changes, validate them
 | 
				
			||||||
                if ( DoEditorValidate() )
 | 
					                if ( DoEditorValidate() )
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    if ( editor->GetValueFromControl( pendingValue, m_selected, wnd ) )
 | 
					                    if ( editor->GetValueFromControl( pendingValue,
 | 
				
			||||||
 | 
					                                                      m_selected,
 | 
				
			||||||
 | 
					                                                      wnd ) )
 | 
				
			||||||
                        valueIsPending = true;
 | 
					                        valueIsPending = true;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                else
 | 
					                else
 | 
				
			||||||
@@ -2914,7 +2916,7 @@ void wxPropertyGrid::HandleCustomEditorEvent( wxEvent &event )
 | 
				
			|||||||
        // Then the property's custom handler (must be always called, unless
 | 
					        // Then the property's custom handler (must be always called, unless
 | 
				
			||||||
        // validation failed).
 | 
					        // validation failed).
 | 
				
			||||||
        if ( !validationFailure )
 | 
					        if ( !validationFailure )
 | 
				
			||||||
            buttonWasHandled = selected->OnEvent( this, wnd, event );
 | 
					            buttonWasHandled = selected->OnEvent( this, editorWnd, event );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // SetValueInEvent(), as called in one of the functions referred above
 | 
					    // SetValueInEvent(), as called in one of the functions referred above
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user