A group that can delete itself
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
A group that can delete itself
I have a number of groups on a card. I want a button on each group that deletes the entire group (including itself) when clicked.
I attach my minimal example and can't find a way to do this. I am sure obvious for the gods on this forum! Any ideas pls?
I attach my minimal example and can't find a way to do this. I am sure obvious for the gods on this forum! Any ideas pls?
- Attachments
-
- delete me.zip
- (1.03 KiB) Downloaded 171 times
Kaveh
Re: A group that can delete itself
Sure, we've got lots of ideas, come back on the 8th day, we're a little busy right now.
signed : local wood sprite
(Just kidding )
First, let me ask if you already saw 'deleteGroup' in the dictionary. If not, it has an example attached to it-
Code: Select all
on deleteGroup -- remove the group being deleted from a list
get lineOffset(the short name of the target,field "Groups List")
delete line it of field "Groups List"
pass deleteGroup
end deleteGroup
Re: A group that can delete itself
Hi Kaveh,
as an admin I can assure there are only humans here in this forum!
Problem:
You cannot delete an object whose script is currently being executed, so the trick is to "outsource" the actual "delete" command!
Do like this:
Button script
When using THE LONG ID we do not need to specify the type of object (button, field, group, whatever).
Card script
Tested and works!
Best
Klaus
as an admin I can assure there are only humans here in this forum!
Problem:
You cannot delete an object whose script is currently being executed, so the trick is to "outsource" the actual "delete" command!
Do like this:
Button script
Code: Select all
on mouseup
put the long ID of the owner of me into yowsayowsayowsa
send "delete_it yowsayowsayowsa" to this cd in 1
end mouseup
Card script
Code: Select all
command delete_it tObject
delete tObject
end delete_it
Best
Klaus
Re: A group that can delete itself
I KNEW you are a fairy queen!
Re: A group that can delete itself
This is a poster for the film Tooth Fairy. The poster art copyright is believed to belong to the distributor of the film, 20th Century Fox, the publisher of the film or the graphic artist.
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: A group that can delete itself
Thank you Klaus. You are still a god when viewed from down here.
Works nicely. My error was putting the delete handler in the group.
Works nicely. My error was putting the delete handler in the group.
Kaveh
Re: A group that can delete itself
Hi Kaveh,
this is just 20 years of experience in working with Livecode and its ancestors (MetaCard, Revolution). And the first three years without internet access (yes, those were the days), so just try & error, hard but highly effective!
Best
Klaus
this is just 20 years of experience in working with Livecode and its ancestors (MetaCard, Revolution). And the first three years without internet access (yes, those were the days), so just try & error, hard but highly effective!
Best
Klaus
-
- Livecode Opensource Backer
- Posts: 508
- Joined: Sun Dec 18, 2011 7:23 pm
- Location: London
- Contact:
Re: A group that can delete itself
I started with Hypercard beta, before Apple had a manual. Been dabbling ever since. The love never goes away...
Kaveh
Re: A group that can delete itself
Meh, you spoiled brats! InterWebz, PSHAW Manuals... we used hieroglyphs!!
When I started, all we had was an Antikythera device, a chisel, and an Abacus, and we LIKED it that way
I can tell you many was the time we had to walk to the temple in 25 cubits of snow, UPHILL both ways, just to attend the ritual sacrifices...
When I started, all we had was an Antikythera device, a chisel, and an Abacus, and we LIKED it that way
I can tell you many was the time we had to walk to the temple in 25 cubits of snow, UPHILL both ways, just to attend the ritual sacrifices...