Drag and Drop Help.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 3
- Joined: Tue Dec 18, 2018 8:08 am
Drag and Drop Help.
I have been working on a drag and drop quiz and have run into a problem. I have been working on learning how to count in spanish. I have the 10 numbers in a group on the side called "numbers" and would like to grab the text from my group "numbers" and then be able to put them in a field called "answers." I am able to put them into the field but not sure how to make it the objects look as if they go from line 1 of the field all the way to line 10. This is my code that I have so far. I am still new to livecode and learning the ropes:) I know that I am missing some code and would appreciate the help. Thanks!
on mouseDown
grab the target
put the short name of the target into tVar
end mouseDown
on mouseUp
repeat with x = 1 to number of fields in group "numbers"
if within(fld "numbers", the loc of the target) then
move fld tVar of group "numbers" to the loc of line x of fld "numbers" in 10 ticks without waiting
disable fld tVar of me
add 1 to x
else
set the loc of fld gBox of me to the startLoc of fld gBox of me
end if
end repeat
end mouseUp
on mouseDown
grab the target
put the short name of the target into tVar
end mouseDown
on mouseUp
repeat with x = 1 to number of fields in group "numbers"
if within(fld "numbers", the loc of the target) then
move fld tVar of group "numbers" to the loc of line x of fld "numbers" in 10 ticks without waiting
disable fld tVar of me
add 1 to x
else
set the loc of fld gBox of me to the startLoc of fld gBox of me
end if
end repeat
end mouseUp
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Drag and Drop Help.
Hi.
We can do this, but I am not sure I understand what you want to do.
When you say you have a "group" on the side, what does that mean? Is it a group of fields? Is it simply several lines of text within a field?
And this:
Remember, we can do this. Write back...
Craig Newman
We can do this, but I am not sure I understand what you want to do.
When you say you have a "group" on the side, what does that mean? Is it a group of fields? Is it simply several lines of text within a field?
And this:
What does that mean? Please give a more detailed instructions. Or wait for someone smarter to chime in.but not sure how to make it the objects look as if they go from line 1 of the field all the way to line 10
Remember, we can do this. Write back...
Craig Newman
-
- Posts: 3
- Joined: Tue Dec 18, 2018 8:08 am
Re: Drag and Drop Help.
Hey dunbark, thanks for the reply. So it is a group of 10 separate fields with the goal to place them within the empty field reflecting the answer field. I have attached a screenshot below and hopefully, you understand my explanation. Ultimately I would like to make a script that will go through and check and make sure the answers are correct by changing the textColor to green if it is correct and red if it is incorrect.
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Drag and Drop Help.
Ah.
So you can:
This should get the contents of each field you drag into a return delimited list. You will want to return the dragged field back to its original location, no? Once all that is done, you can test the contents of the list to see if the lines are in the correct order.
Craig
So you can:
Code: Select all
on mouseDown
if "field" is in the name of the target then grab the target
end mouseDown
on mouseUp
put target & return after fld yourTestField
end mouseUp
Craig
-
- Posts: 3
- Joined: Tue Dec 18, 2018 8:08 am
Re: Drag and Drop Help.
Thank you so much! I have the rest figured out from here
-
- VIP Livecode Opensource Backer
- Posts: 9648
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Drag and Drop Help.
Good.
I neglected to suggest that the above handlers should be placed in the card script, and that you may want to further restrict the grab only to the fields that you want.
Craig
I neglected to suggest that the above handlers should be placed in the card script, and that you may want to further restrict the grab only to the fields that you want.
Craig