Create a button that deletes objects when they touch it?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
sinep
Posts: 12
Joined: Sat Jun 13, 2015 5:19 am

Create a button that deletes objects when they touch it?

Post by sinep » Fri Jun 19, 2015 8:33 am

I'm trying to create a button that acts as a trash can of sorts.

The button will sit at the bottom of the screen and I would like it so any object that it slid into it will be deleted.

I'm not sure why it's so hard to find an example. Thanks for any help.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Create a button that deletes objects when they touch it?

Post by jmburnod » Fri Jun 19, 2015 4:37 pm

Hi Sinep,

I dont know if that way is the best way but you can try it

object script obj you want delete :

Code: Select all

on mousedown
   grab me
end mousedown

on mouseUp
   deControlMU
end mouseUp
cd script :

Code: Select all

on deControlMU
   put the short id of the target into tTargetID
   if intersect(the target,btn "bPoubelle") then
      send "deleteMyObject tTargetID" to me in 10 milliseconds
   end if
end deControlMU

on deleteMyObject pID
   delete control id pID
end deleteMyObject
Best regards
Jean-Marc
https://alternatic.ch

Post Reply