Drag'n'Drop Properties

Help
2009-02-01
2013-05-22
  • Hi,

    I would like to add a custom property with drag'n'drop functionality to a property grid, i.e. so that I could assign data to the property by dragging. For wxWidgets drag'n'drop I use wxWindow::SetDropTarget() in other places where I need a window to accept drops, but with property grid I don't have a window of a property so that I could tie drop target to it. Any suggestions how I should implement this feature?

    Thanks, Jarkko

     
    • Jaakko Salli
      Jaakko Salli
      2009-02-01

      I guess you could define a new wxDropTarget class for the entire grid, and translate coordinates given in wxDropTarget::OnData() to an actual property (using wxPropertyGrid::HitTest()). Note that you probably want to use result of propgrid->GetCanvas() as the window for which you call SetDropTarget().

      HTH,
        Jaakko

       
    • Ah, that might work. I'll give it a shot. Thanks!

      Cheers, Jarkko

       
    • I implemented the drag'n'drop feature with the HitTest() like you suggested, and it's working great, except HitTest() seems to return a wrong property when the window is being scrolled. Is this a known issue?

      Cheers, Jarkko

       
      • Jaakko Salli
        Jaakko Salli
        2009-02-13

        HitTest() takes logical coordinates. That is, you need probably need to call wxScrolledWindow::CalcUnscrolledPosition().

        I'll update the documentation to be more clear on this.

        Regards,
        Jaakko

         
    • Ah, ok. Yes this fixes the problem except I had to use CalcScrolledPosition();

      Thanks, Jarkko