Drag and Drop HELP

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
nitya
Posts: 3
Joined: Tue Dec 14, 2010 10:42 am

Drag and Drop HELP

Post by nitya » Thu Dec 30, 2010 6:47 pm

Hello

I am new to live code. I am try to develope apps based on drag and drop.

please see attached pic.
PartsOfTheBody2.jpg
PartsOfTheBody2.jpg (102.85 KiB) Viewed 3570 times
User have to drag and drop part of the body label to relevant box.

if drop on correct box then label centre location equal to correct box centre location

if drop on wrong box then set location of label back to start point.

Questions
1) how to track and store start location of label
2) how to set label location to box location if answer is correct
3) how to set label location back to start location

So far my code is as following where Code in RED not working and Code in Blue is working fine.

on touchStart
--get startlocation
end touchStart

-- dragORdrop is custom property set either drag or drop

on touchmove pid,pX,pY

if the dragORdrop of the target is "drag" then
set the loc of the target to pX, pY
end if

end touchmove


Many thanks in advance.

Randy Hengst
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 153
Joined: Thu Jun 29, 2006 4:16 pm

Re: Drag and Drop HELP

Post by Randy Hengst » Thu Dec 30, 2010 8:46 pm

Hello nitya,

I've attached an example of one way to do this.

See the card script for the handlers.

take care
randy hengst
Attachments
Parts of the body.livecode.zip
Parts of body example stack
(99.29 KiB) Downloaded 325 times

nitya
Posts: 3
Joined: Tue Dec 14, 2010 10:42 am

Re: Drag and Drop HELP

Post by nitya » Fri Dec 31, 2010 12:07 am

Dear Randy

Your example rocks. I will try and run code on IPAD simulator.
Many thanks for help.

Regards
Nitya

cruddydan
Posts: 15
Joined: Tue Jan 18, 2011 10:57 pm

Re: Drag and Drop HELP

Post by cruddydan » Tue Jan 25, 2011 6:53 am

It would be nice to see this solution using the "touch" events, not the "grab" command.

Post Reply

Return to “iOS Deployment”