David Barrett-Lennard
2014-09-17 23:29:50 UTC
I recently posted the text below to the wxWidgets discussion forum and it
was suggested it be discussed here in order to reach the core developers
David
(first post)
In my use case a window needs to support dropping of data of different
formats at different (x,y) positions. It seems I need
wxDropTarget::OnDragOver to return wxDragNone if and only if the data
source is incompatible (in the sense of an accepted wxDataFormat) at the
given (x,y) position passed to OnDragOver. I cannot see how to do this.
The fact that the acceptable data format is a function of (x,y) suggests I
need to call wxDropTarget::SetDataObject from my implementation of
wxDropTarget::OnDragOver. Is that allowed? In any case the only function I
see that seems to test for data format compatibility is
wxDropTarget::GetData which returns a bool for whether it was successful.
However the documentation says wxDropTarget::GetData can only be called
from wxDropTarget::OnData.
(second post)
I've studied the MS Windows implementation in the version 3.0.0 wxWidgets
source code (see src/msw/ole/droptgt.cpp), and as far as I can tell the
limitation arises with wxWidgets, not from Microsoft. I don't know about
other platforms.
When the mouse enters the window during a drag operation,
wxIDropTarget::DragEnter is called. This is passed an IDataObject (a
Microsoft COM interface) associated with the source. MSWIsAcceptedData is
called on the wxDropTarget, which checks for compatability between the
target wxDataObject (currently set in the wxDropTarget) with the source
IDataObject. The subsequent calls to wxIDropTarget::DragOver do not check
for data format compatibility. Clearly it is assumed the appropriate target
wxDataObject is independent of position.
I don't find that restriction reasonable and I cannot think of a work
around. This is a shame, it means wxWidgets is unsuitable for drag and drop
in my application.
Perhaps it's possible to change wxWidgets to address this shortcoming in a
backwards compatible way. Maybe it should be made possible to call
SetDataObject from OnEnter, OnDragOver, OnDrop or OnData. SetDataObject
currently has a void return type. It could be changed to bool and when it
is called from an OnXXX method it indicates whether the given wxDataObject
is acceptable for the current source IDataObject (which is available in the
member wxDropTarget::m_pIDataSource whenever an OnXXX function is called).
It would be appropriate to initialise wxDropTarget::m_pIDataSource to NULL
in the constructor and to reset it back to NULL when the leave event occurs
(neither of which is done at the moment). That way SetDataObject can work
properly when it's called when no drag operation is in progress. At the
moment the rules on when SetDataObject can or should be called is not
documented and not validated with assertions.
was suggested it be discussed here in order to reach the core developers
David
(first post)
In my use case a window needs to support dropping of data of different
formats at different (x,y) positions. It seems I need
wxDropTarget::OnDragOver to return wxDragNone if and only if the data
source is incompatible (in the sense of an accepted wxDataFormat) at the
given (x,y) position passed to OnDragOver. I cannot see how to do this.
The fact that the acceptable data format is a function of (x,y) suggests I
need to call wxDropTarget::SetDataObject from my implementation of
wxDropTarget::OnDragOver. Is that allowed? In any case the only function I
see that seems to test for data format compatibility is
wxDropTarget::GetData which returns a bool for whether it was successful.
However the documentation says wxDropTarget::GetData can only be called
from wxDropTarget::OnData.
(second post)
I've studied the MS Windows implementation in the version 3.0.0 wxWidgets
source code (see src/msw/ole/droptgt.cpp), and as far as I can tell the
limitation arises with wxWidgets, not from Microsoft. I don't know about
other platforms.
When the mouse enters the window during a drag operation,
wxIDropTarget::DragEnter is called. This is passed an IDataObject (a
Microsoft COM interface) associated with the source. MSWIsAcceptedData is
called on the wxDropTarget, which checks for compatability between the
target wxDataObject (currently set in the wxDropTarget) with the source
IDataObject. The subsequent calls to wxIDropTarget::DragOver do not check
for data format compatibility. Clearly it is assumed the appropriate target
wxDataObject is independent of position.
I don't find that restriction reasonable and I cannot think of a work
around. This is a shame, it means wxWidgets is unsuitable for drag and drop
in my application.
Perhaps it's possible to change wxWidgets to address this shortcoming in a
backwards compatible way. Maybe it should be made possible to call
SetDataObject from OnEnter, OnDragOver, OnDrop or OnData. SetDataObject
currently has a void return type. It could be changed to bool and when it
is called from an OnXXX method it indicates whether the given wxDataObject
is acceptable for the current source IDataObject (which is available in the
member wxDropTarget::m_pIDataSource whenever an OnXXX function is called).
It would be appropriate to initialise wxDropTarget::m_pIDataSource to NULL
in the constructor and to reset it back to NULL when the leave event occurs
(neither of which is done at the moment). That way SetDataObject can work
properly when it's called when no drag operation is in progress. At the
moment the rules on when SetDataObject can or should be called is not
documented and not validated with assertions.
--
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users
Please read http://www.wxwidgets.org/support/mlhowto.htm before posting.
To unsubscribe, send email to wx-users+***@googlegroups.com
or visit http://groups.google.com/group/wx-users