Page 1 of 1

DropEffect OverrideDropEffect

PostPosted: Tue Aug 11, 2015 11:20 am
by RichardD
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);
  DMTextTarget1.OverrideDropEffects[deCopy] := deMove;

Unfortunately, this gives me the black barred circle (ie. as in cannot drop here) instead of the expected move effect.

Re: DropEffect OverrideDropEffect

PostPosted: Tue Aug 18, 2015 12:14 pm
by DropMaster
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.

Re: DropEffect OverrideDropEffect

PostPosted: Wed Aug 19, 2015 7:45 am
by DropMaster
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.