Drag and Drop Question - Determining Drop Source and Canceling a drop

Hi Everybody,

I am implementing a drag and drop interface and have some questions.

I have a drop source that contains different kinds of objects. When I
drop this source on a target of incompatible type, I wish to cancel
the drop (plus show visual feedback that it is not valid).

Here is my question - When I dragover the possible targets, I do not
know my source data type. The source data type is found only in the
OnData method. But then it is too late to show that the drop was
invalid (or is it? I tried returning wx.DragCancel instead of "d" if I
found the types to be incompatible but that did not change the drop
icon). Is it possible to determine the Drop source before the drop
takes place and thus perform a source/target comparison before
OnData()?

Thanks,
-Kartic
PS: I pretty much followed the CustomDandD.py in wx Demo.

Hi All,

Could someone please help me here? I really need this functionality.

Thank you,
-Kartic

···

---------- Forwarded message ----------
From: K K <kartic0@gmail.com>
Date: Aug 3, 2005 3:30 AM
Subject: Drag and Drop Question - Determining Drop Source and Canceling a drop
To: wxPython-users@lists.wxwidgets.org

Hi Everybody,

I am implementing a drag and drop interface and have some questions.

I have a drop source that contains different kinds of objects. When I
drop this source on a target of incompatible type, I wish to cancel
the drop (plus show visual feedback that it is not valid).

Here is my question - When I dragover the possible targets, I do not
know my source data type. The source data type is found only in the
OnData method. But then it is too late to show that the drop was
invalid (or is it? I tried returning wx.DragCancel instead of "d" if I
found the types to be incompatible but that did not change the drop
icon). Is it possible to determine the Drop source before the drop
takes place and thus perform a source/target comparison before
OnData()?

Thanks,
-Kartic
PS: I pretty much followed the CustomDandD.py in wx Demo.

Hello Kartic:

In brief, I think you will have to encode the identity of the source into a
custom data object, and pass this along with any other data. See the
example of Custom Drag and Drop in the demo, for how to set up a
composite data object. Then, in the OnData method of your drop target,
you check the data for the identity of the source. If you don't like it, then
return wx.DragNone or wx.DragCancel, instead of wx.DragCopy or
wx.DragMove if the operation should proceed.

Best of luck.

···

On 8/21/05, K K <kartic0@gmail.com> wrote:

Hi All,

Could someone please help me here? I really need this functionality.

Thank you,
-Kartic

---------- Forwarded message ----------
From: K K <kartic0@gmail.com>
Date: Aug 3, 2005 3:30 AM
Subject: Drag and Drop Question - Determining Drop Source and Canceling a drop
To: wxPython-users@lists.wxwidgets.org

Hi Everybody,

I am implementing a drag and drop interface and have some questions.

I have a drop source that contains different kinds of objects. When I
drop this source on a target of incompatible type, I wish to cancel
the drop (plus show visual feedback that it is not valid).

Here is my question - When I dragover the possible targets, I do not
know my source data type. The source data type is found only in the
OnData method. But then it is too late to show that the drop was
invalid (or is it? I tried returning wx.DragCancel instead of "d" if I
found the types to be incompatible but that did not change the drop
icon). Is it possible to determine the Drop source before the drop
takes place and thus perform a source/target comparison before
OnData()?

Thanks,
-Kartic
PS: I pretty much followed the CustomDandD.py in wx Demo.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

The way I solved this problem was to add a GiveFeedback() method to my
wx.DropSource object. In this method, I altered the cursor as needed, and
used the return value to indicate whether I was over-riding the default
feedback or not.

You can find an example of how to use this at
http://www2.wcer.wisc.edu/Transana/Download/DragDropBug.zip. This code
actually demonstrated a bug in GiveFeedback on the Mac that has now been
fixed, but it should give you an idea of how to use GiveFeedback.

Good luck,
David

···

-----Original Message-----
From: K K [mailto:kartic0@gmail.com]
Sent: Sunday, August 21, 2005 5:47 PM
To: wxPython-users@lists.wxwidgets.org
Subject: [wxPython-users] Fwd: Drag and Drop Question -
Determining Drop Source and Canceling a drop

Hi All,

Could someone please help me here? I really need this functionality.

Thank you,
-Kartic

---------- Forwarded message ----------
From: K K <kartic0@gmail.com>
Date: Aug 3, 2005 3:30 AM
Subject: Drag and Drop Question - Determining Drop Source and
Canceling a drop
To: wxPython-users@lists.wxwidgets.org

Hi Everybody,

I am implementing a drag and drop interface and have some questions.

I have a drop source that contains different kinds of
objects. When I drop this source on a target of incompatible
type, I wish to cancel the drop (plus show visual feedback
that it is not valid).

Here is my question - When I dragover the possible targets, I
do not know my source data type. The source data type is
found only in the OnData method. But then it is too late to
show that the drop was invalid (or is it? I tried returning
wx.DragCancel instead of "d" if I found the types to be
incompatible but that did not change the drop icon). Is it
possible to determine the Drop source before the drop takes
place and thus perform a source/target comparison before OnData()?

Thanks,
-Kartic
PS: I pretty much followed the CustomDandD.py in wx Demo.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwidgets.org

David and Michael,

Thanks for your inputs. I will take a look at the methods and see
which suits my purpose best.

I appreciate your timely assistance.

-Kartic

···

On 8/22/05, David Woods <dwoods@wcer.wisc.edu> wrote:

The way I solved this problem was to add a GiveFeedback() method to my
wx.DropSource object. In this method, I altered the cursor as needed, and
used the return value to indicate whether I was over-riding the default
feedback or not.

You can find an example of how to use this at
http://www2.wcer.wisc.edu/Transana/Download/DragDropBug.zip. This code
actually demonstrated a bug in GiveFeedback on the Mac that has now been
fixed, but it should give you an idea of how to use GiveFeedback.

Good luck,
David

> -----Original Message-----
> From: K K [mailto:kartic0@gmail.com]
> Sent: Sunday, August 21, 2005 5:47 PM
> To: wxPython-users@lists.wxwidgets.org
> Subject: [wxPython-users] Fwd: Drag and Drop Question -
> Determining Drop Source and Canceling a drop
>
>
> Hi All,
>
> Could someone please help me here? I really need this functionality.
>
> Thank you,
> -Kartic
>
> ---------- Forwarded message ----------
> From: K K <kartic0@gmail.com>
> Date: Aug 3, 2005 3:30 AM
> Subject: Drag and Drop Question - Determining Drop Source and
> Canceling a drop
> To: wxPython-users@lists.wxwidgets.org
>
>
> Hi Everybody,
>
> I am implementing a drag and drop interface and have some questions.
>
> I have a drop source that contains different kinds of
> objects. When I drop this source on a target of incompatible
> type, I wish to cancel the drop (plus show visual feedback
> that it is not valid).
>
> Here is my question - When I dragover the possible targets, I
> do not know my source data type. The source data type is
> found only in the OnData method. But then it is too late to
> show that the drop was invalid (or is it? I tried returning
> wx.DragCancel instead of "d" if I found the types to be
> incompatible but that did not change the drop icon). Is it
> possible to determine the Drop source before the drop takes
> place and thus perform a source/target comparison before OnData()?
>
> Thanks,
> -Kartic
> PS: I pretty much followed the CustomDandD.py in wx Demo.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
> For additional commands, e-mail:
> wxPython-users-help@lists.wxwidgets.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org

Hello Kartic:

I just re-read your original inquiry, and I realize that my answer was not
directed properly to your question. If I now understand your problem, it
is that certain drop targets must show a "No Drop" cursor for some types
of drop sources, and a "Drop OK" cursor for others. I have never done this
myself, but it should work to create a specific type of custom data object
for each possible source. Then, make your drop target objects such that
they will only accept the custom data types that you wish. If you do this,
the effect you want should happen automatically, with no further effort
on your part.

Hope this helps more than my last comment.

···

On 8/22/05, K K <kartic0@gmail.com> wrote:

David and Michael,

Thanks for your inputs. I will take a look at the methods and see
which suits my purpose best.

I appreciate your timely assistance.

-Kartic