Page 1 of 2

Help needed with drag and drop

Posted: Mon Nov 15, 2010 11:43 pm
by user#606
I wish to drag a file name to a field, drop it and copy that content to another field and clear the "dropped into" field.

on dragDrop
beep
put field "droppatch" into field "file 1"
put empty into field "droppatch"
pass dragDrop
end dragDrop

What happens is the field name drops ok, but it just stays there hilighted and nothing apears in the other field.
The BEEP works (used to see what is happening).
If I follow with another file, the earlier drop gets copied to the other field.

What have I missed?

Re: Help needed with drag and drop

Posted: Tue Nov 16, 2010 1:33 am
by Dixie
606...

Code: Select all

on dragDrop
   put the dragData["text"]into line 1 of fld 1
   put URL ("file:" & line 1 of me) into fld 2
   put empty into fld 1
end dragDrop
Is this what you want to do ?... I made a stack with 2 fields... put the above script into the script of fld 1.... and then drag a text file onto fld 1. The contents of the textfile appear in field 2.

be well

Dixie

Re: Help needed with drag and drop

Posted: Tue Nov 16, 2010 10:46 am
by user#606
Thank you for your suggestion Dixi, however it is not what I want at all.
Perhaps I simplified the task too much.

The actual issue is that I want to drag a file address (not the file) onto a common drop zone.
Depending on the prefix of the file name, the address will be directed to a particular field.

I want the dropped address text to go from the drop zone to the destination and clear the drop zone as a single operation.
Just as you would move a file to the trash bin!

What I dont understand from the simple code is that it must be working or the beep would not sound, though the copy of text and subsequent clearing of the drop zone does not. If I put the code in a button and click it, it works!

Re: Help needed with drag and drop

Posted: Tue Nov 16, 2010 12:45 pm
by Klaus
Hi 606,

Code: Select all

on dragDrop
      beep  
      put field "droppatch" into field "file 1"
      put empty into field "droppatch"
## At this point the actual dropping of the filename has NOT yet taken playe!
## That's why the target field remains empty when this is executed the first time!

      pass dragDrop
## NOW the filename is in the dropzone, but its too late :-)
end dragDrop
We nee to let the drop occur first and then take the other action AFTer this has happened
Try somehting like this:

Code: Select all

on dragDrop
      beep
      send "the_action" to me in 10 millisesc
      ## enough time to drop the filename
  
      pass dragDrop
end dragDrop

command the_action
      put field "droppatch" into field "file 1"
      put empty into field "droppatch"
end the_action
Not tested but should work! (Famous last words :D)

Best

Klaus

Re: Help needed with drag and drop

Posted: Tue Nov 16, 2010 4:52 pm
by a-revuser
I have almost resolved the problem.
I have used this code
on dragDrop
put the dragData["text"]into line 1 of field "file 1"
end dragDrop

and it does everything necessary.
Just one odd thing, the insertion point is left (not flashing though) in the drop zone.
I am not sure what I expected to happen with it, perhaps if it just vanished would be good.
The mouse works fine afterwards and text cannot be entered at the insertion point, so is probably just a cosmentic thing. Any comments?

Thank you both Dixie and Klaus, both answers have shown the way.

Re: Help needed with drag and drop

Posted: Tue Nov 16, 2010 4:52 pm
by a-revuser
I have almost resolved the problem.
I have used this code
on dragDrop
put the dragData["text"]into line 1 of field "file 1"
end dragDrop

and it does everything necessary.
Just one odd thing, the insertion point is left (not flashing though) in the drop zone.
I am not sure what I expected to happen with it, perhaps if it just vanished would be good.
The mouse works fine afterwards and text cannot be entered at the insertion point, so is probably just a cosmentic thing. Any comments?

Thank you both Dixie and Klaus, both answers have shown the way.

Re: Help needed with drag and drop

Posted: Tue Nov 16, 2010 5:06 pm
by Klaus
Hi a-revuser,

just add a "select empty" at the end of your handler!


Best

Klaus

Re: Help needed with drag and drop

Posted: Tue Nov 16, 2010 11:53 pm
by user#606
I cannot make the select empty work at all.
I have also noticed the insertion point is not working properly in the script editor since the dragdrop command.
I have to exit and restart rev to get back to normal.
this simple action is far from satisfactory.
any good ideas on this one?

Re: Help needed with drag and drop

Posted: Wed Nov 17, 2010 12:56 am
by Dixie
606...

I have attached a stack... look at the scripts of fld 1 and fld 2... the insertion point now disappears...

be well

Dixie

Re: Help needed with drag and drop

Posted: Wed Nov 17, 2010 11:10 am
by Mark
User,

You encountered a bug in the script editor. Whenever you drag anything over the script editor, you will get stuck. Always close the script editor before starting a drag-and-drop.

Kind regards,

Mark

Re: Help needed with drag and drop

Posted: Wed Nov 17, 2010 11:51 am
by a-revuser
Hi Dixie, Klaus,
I attach an extract of the stack with basic instructions so you can see the effect for yourself.
With Dixie's stack, it did not work with the drag in from a file list in Explorer. This is key to the process.
Of course, no script is actualy required to drag text from one field to another, if only it were easy from some other source.

I hope you can help

Re: Help needed with drag and drop

Posted: Wed Nov 17, 2010 11:54 am
by Dixie
Hi 606...

I don't see the extract you mention..

Dixie

Re: Help needed with drag and drop

Posted: Wed Nov 17, 2010 11:57 am
by a-revuser
I am trying to sort out where it went.
I have uploaded the file twice so far, once as a livecoad and once as a zipfile. Sorry

Re: Help needed with drag and drop

Posted: Wed Nov 17, 2010 12:01 pm
by Mark
User,

Are you dragging a file name (text) or a file?

Mark

Re: Help needed with drag and drop

Posted: Wed Nov 17, 2010 12:01 pm
by Dixie
err... email ?... john@ihouse.on-rev.com

Dixie