Help needed with drag and drop
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Help needed with drag and drop
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?
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
606...
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
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
be well
Dixie
Re: Help needed with drag and drop
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!
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
Hi 606,
We nee to let the drop occur first and then take the other action AFTer this has happened
Try somehting like this:
Not tested but should work! (Famous last words
)
Best
Klaus
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
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

Best
Klaus
Re: Help needed with drag and drop
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.
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
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.
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
Hi a-revuser,
just add a "select empty" at the end of your handler!
Best
Klaus
just add a "select empty" at the end of your handler!
Best
Klaus
Re: Help needed with drag and drop
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?
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
606...
I have attached a stack... look at the scripts of fld 1 and fld 2... the insertion point now disappears...
be well
Dixie
I have attached a stack... look at the scripts of fld 1 and fld 2... the insertion point now disappears...
be well
Dixie
- Attachments
-
- untitled folder.zip
- (2.1 KiB) Downloaded 315 times
Re: Help needed with drag and drop
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
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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Help needed with drag and drop
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
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
Hi 606...
I don't see the extract you mention..
Dixie
I don't see the extract you mention..
Dixie
Re: Help needed with drag and drop
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
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
User,
Are you dragging a file name (text) or a file?
Mark
Are you dragging a file name (text) or a file?
Mark
Last edited by Mark on Wed Nov 17, 2010 12:49 pm, edited 1 time in total.
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode