DropEffect OverrideDropEffect

Support forum for our inter-application drag-n-drop components.

DropEffect OverrideDropEffect

Postby RichardD » Tue Aug 11, 2015 11:20 am

Please describe how I can use this, I tried multiple things but I cannot get it to act the way I want it.

Here's the situation:
I have 2 forms. Both can accept and receive drag and drops. Besides these forms, drops can obviously also come from elsewhere (ie. Windows explorer, Outlook, etc.)

So not knowing where the drag came from, how can I override the drop effect when "accepting a drop" (i.e. entering a form that accepts drops).

Let's say I want to force a move effect, I tried this without sucess:
Code: Select all
procedure TUaarSalesMain.DMTextTarget1DragEnter(Sender: TObject;
  Effect: TDropEffect; X, Y: Integer);
begin
  DMTextTarget1.OverrideDropEffects[deCopy] := deMove;
end;


Unfortunately, this gives me the black barred circle (ie. as in cannot drop here) instead of the expected move effect.
RichardD
 
Posts: 2
Joined:
Tue Aug 19, 2014 4:13 pm

Re: DropEffect OverrideDropEffect

Postby DropMaster » Tue Aug 18, 2015 12:14 pm

I'm not quite sure I understand the question, in particular how it relates to where the drop starts.

I am able to set up a TDMTextTarget on a form to accept text drags. Then if I do
Code: Select all
DMTextTarget1.OverrideDropEffects[deCopy] := deMove;


and use the key combination for copy (the default is move) the move cursor never changes to a copy cursor.

If instead you want the default to be copy and then move if you hold down Ctrl, you can do

Code: Select all
DMTextTarget1.OverrideDropEffects[deCopy] := deMove;
DMTextTarget1.OverrideDropEffects[deMove] := deCopy;


Please follow up with more details or a small example if your question is not answered by this.
_________________________
DropMaster Support
DropMaster
 
Posts: 23
Joined:
Fri Apr 15, 2011 6:32 am

Re: DropEffect OverrideDropEffect

Postby DropMaster » Wed Aug 19, 2015 7:45 am

There's one more thing to consider.

Your code says "if I'm trying to accept a copy, instead accept a move." However, if a move is not available as one of the drop effects provided by the source, then the cursor will turn to a "no drop" one as you've asked for something that's not available.

The default setting for the property TDMTextSource.DropEffects is the singleton set [deCopy]. If the source of your drop is a TDMTextSource with unchanged properties, and you replace deCopy with deMove, there's nothing left to accept, so you get a "no drop" cursor. (Incidentially, that was a deliberate design choice since a deMove requires you. as the TDMTexTSource provider, to write code to delete something once a "move" drop has been processed, but a deCopy doesn't require anything to happen at the source.

If you want to be able to source either a move or a copy from a TDMTextSource, you must add deMove to its DropEffects, and then handle the deletion effects of a move in OnAfterDrop if the DroppedOK parameter is true.

Hope this helps.
_________________________
DropMaster Support
DropMaster
 
Posts: 23
Joined:
Fri Apr 15, 2011 6:32 am


Return to DropMaster

Who is online

Users browsing this forum: No registered users and 1 guest

cron