Drag and drop text between fields
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Drag and drop text between fields
Im sure I have seen this somewhere but cant for the life of me find it again.
If you have two list boxes, what is the code needed to allow a user to drag a line from one into the other.
I want the user to be able to select a line from a field, and then either use the 'add' button to add it into the other field or simply drag and drop it, but I cant find the code to do a drag and drop.
Thanks
Andy
If you have two list boxes, what is the code needed to allow a user to drag a line from one into the other.
I want the user to be able to select a line from a field, and then either use the 'add' button to add it into the other field or simply drag and drop it, but I cant find the code to do a drag and drop.
Thanks
Andy
Thanks Nigel,
I had a look at that and it seemed to work fine for text fields, but as soon as you turned it into a list field the dragstart didnt seem to fire.
I was looking for a way for a user to be able to select a line from a list, and drag that over to another field, but the dragstart doesnt seem to fire at all.
If I do it from a text field it works fine, but then I dont get the list behaviour.
Andy
I had a look at that and it seemed to work fine for text fields, but as soon as you turned it into a list field the dragstart didnt seem to fire.
I was looking for a way for a user to be able to select a line from a list, and drag that over to another field, but the dragstart doesnt seem to fire at all.
If I do it from a text field it works fine, but then I dont get the list behaviour.
Andy
thank you
thank you for sharing, it really helps others to understand.


How to delete source line after drag and drop into target
Hello:
I am evaluating Revolution and have been trying to perform a drag and drop operation where the field from the source is deleted after it is dropped in the target (moved). I am using two scrolling list fields called "List1" and List2" and the code I have thus far is as follows:
On Source scrolling list field:
-------------------------------------------------------------
on mousedown
set the dragData["text"] to the selectedtext of me
set locktext of field "List2" to false
pass mousedown
end mousedown
--------------------------------------------------------------
On Target Scrolling list field:
--------------------------------------------------------------
on dragdrop
put the dragdata["Text"] && CR after me
set the locktext of me to true
if the selectedline is empty then
-- do nothing
else
delete the selectedline
end if
end dragdrop
--------------------------------------------------------------
The problem is that I am left with an empty line in the source (List1).
Any ideas? Thank you
I am evaluating Revolution and have been trying to perform a drag and drop operation where the field from the source is deleted after it is dropped in the target (moved). I am using two scrolling list fields called "List1" and List2" and the code I have thus far is as follows:
On Source scrolling list field:
-------------------------------------------------------------
on mousedown
set the dragData["text"] to the selectedtext of me
set locktext of field "List2" to false
pass mousedown
end mousedown
--------------------------------------------------------------
On Target Scrolling list field:
--------------------------------------------------------------
on dragdrop
put the dragdata["Text"] && CR after me
set the locktext of me to true
if the selectedline is empty then
-- do nothing
else
delete the selectedline
end if
end dragdrop
--------------------------------------------------------------
The problem is that I am left with an empty line in the source (List1).
Any ideas? Thank you

Hi Gus,
yep, looks like "delete the selectedline" only puts EMPTY into that line and not really deletes it.
Put this into the script of your target scrolling field:
Tested and works 
Best from germany
Klaus
yep, looks like "delete the selectedline" only puts EMPTY into that line and not really deletes it.
Put this into the script of your target scrolling field:
Code: Select all
on dragdrop
put the dragdata["Text"] && CR after me
set the locktext of me to true
if the selectedline <> empty then
delete line (the hilitedline of fld "list1") of fld "list1"
end if
end dragdrop

Best from germany
Klaus