Deleting button while executing it's script

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Deleting button while executing it's script

Post by adventuresofgreg » Sun Sep 30, 2012 3:34 pm

Hello: what is the best way to handle this? I need to delete a button from it's own script, but you can't delete an object whose script holds a currently executing handler.

Klaus
Posts: 14213
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Deleting button while executing it's script

Post by Klaus » Sun Sep 30, 2012 4:33 pm

Hi Greg,

handle the deletion in the card script, something like this:

Code: Select all

command delete_button tName
  if there is a btn tName then
     delete btn tName
  end if
end delete_button
In the button:

Code: Select all

on mouseup
   ## your stuff here
   put the short name of me into tName
   send "delete_button tName" to this cd in 1
end mouseup
Tested and works :D

Best

Klaus

adventuresofgreg
Posts: 349
Joined: Tue Oct 28, 2008 1:23 am
Contact:

Re: Deleting button while executing it's script

Post by adventuresofgreg » Sun Sep 30, 2012 5:36 pm

Thanks Klaus. that will work

Post Reply