Adding an editor for wxPropertyCategory

Help
2009-03-06
2013-05-22
  • Hi,

    Is there a way to add an editor for wxPropertyCategory? I tried to call wxPropertyGrid::SetPropertyEditor() for a category in a property sheet but it doesn't seem to have any effect. I would like to add couple of buttons to the category like the "MultipleButtons" property in the property grid sample application. Or is there some other way to implement this?

    Thanks, Jarkko

     
    • Hmh, I think I can make it work by using wxStringProperty instead of wxPropertyCategory.

       
      • Jaakko Salli
        Jaakko Salli
        2009-03-06

        Yes, absolutely. I was just going to suggest that you do that ;) wxPropertyCategory is really not designed to have editor control. Although it should be quite possible to modify wxPropertyGrid to allow it, wxPropertyCategories are treated as special cases in so many places in the code, that the effort would be difficult and time consuming.

        Regards,
        Jaakko

         
    • This seems to work well, expect that in some cases the only editor control I want is the wxPGMultiButton. If I don't call ::CreateControls() of the editor's parent class when creating the controls and initialize the wxPGWindowList with the returned value, buttons are properly displayed as the editor controls, but no events are issued when pressing the buttons (i.e. there are no calls to ::OnEvent()). I don't know if this is because the returned wxPGWindowList from my editors ::CreateControls() is empty in that case and I call only wxPGWindowList::SetSecondary() passing the wxPGMultiButton* as the argument. How should I initialize the wxPGWindowList so that button presses cause events properly when it is the only editor control for a property?

      Thanks, Jarkko

       
      • Jaakko Salli
        Jaakko Salli
        2009-03-09

        This was a bug, should be fixed now in SVN trunk.

        Thanks,
          Jaakko

         
    • This seems to work well, expect that in some cases the only editor control I want is the wxPGMultiButton. If I don't call ::CreateControls() of the editor's parent class when creating the controls and initialize the wxPGWindowList with the returned value, buttons are properly displayed as the editor controls, but no events are issued when pressing the buttons (i.e. there are no calls to ::OnEvent()). I don't know if this is because the returned wxPGWindowList from my editors ::CreateControls() is empty in that case and I call only wxPGWindowList::SetSecondary() passing the wxPGMultiButton* as the argument. How should I initialize the wxPGWindowList so that button presses cause events properly when it is the only editor control for a property?

      Thanks, Jarkko

       
    • Thanks, seems to work now! Only small thing I noticed is that if I return true from the OnEvent() it crashes for wxPGTextCtrlEditor and wxPGChoiceEditor I tried.

       
      • Jaakko Salli
        Jaakko Salli
        2009-03-10

        Yes, if you return true from OnEvent(), it assumes the editor value has changed, and the subsequent call to wxPGTextCtrlEditor::GetValueFromControl() naturally expects that the wxTextCtrl editor is valid (which it of course is not in your case). So maybe it would be better not to derive your multi-button editor from wxPGTextCtrlEditor, or alternatively just create a read-only wxTextCtrl.

        Regards,
        Jaakko