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?
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().
Ah, that might work. I'll give it a shot. Thanks!
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?
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.
Ah, ok. Yes this fixes the problem except I had to use CalcScrolledPosition();
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.