Page 1 of 1

Deleting an object !SOLVED!

Posted: Mon Oct 29, 2012 4:56 am
by nlexa
From the livecode dictionary:
You cannot delete the object whose script holds a currently executing handler.
I have a group of controls. In that group of controls is a button with an x on it, like the little x in the top right hand corner of my browser window.
When I press the x I want the the button and the group it belongs to, to be deleted.

So I try to be clever and call commands on the card or on the stack that delete the group - but this doesn't work because "end mouseUp" in the script of the x button is the last thing to happen and therefore a "currently executing handler"

It would be easy just to set the visible to false but I actually want to delete it. Perhaps I just have to be creative about how my program works. But if anyone knows how to get something to delete itself please share

Re: Deleting an object

Posted: Mon Oct 29, 2012 5:45 am
by FourthWorld
A timer would allow this:

-- button:
on mouseUp
send "DeleteThang the short name of the parent of me" to this cd in 20 millisecs
end mouseUp

-- card:
on DeleteThang pGroup
delete grp pGroup
end DeleteThang

Re: Deleting an object

Posted: Thu Nov 01, 2012 2:37 am
by nlexa
Thanks heaps! Why I didn't think of this before I don't know but that's the power of the forum :D