Group deleting itself via script (answered)

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
monki
Posts: 59
Joined: Tue Dec 13, 2011 10:56 pm

Group deleting itself via script (answered)

Post by monki » Thu Mar 02, 2017 8:12 pm

I have groups that act as markers on a map image. Each of these groups is a rectangle, text field, and button. I would like to have the user click on a button in the group and delete that group. How to do this? I can remove the group, but it's still hanging around. How do I get rid of it without selecting it and hitting the "delete" button?

Thanks
Last edited by monki on Thu Mar 02, 2017 10:29 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Delete Group via script

Post by dunbarx » Thu Mar 02, 2017 8:40 pm

Hi.

Not quite sure what you mean, but if you make two groups on a new card, and ask for the number of groups, you will get 2.

If you delete one group, and ask again, you will get 1. Delete really deletes.

Craig Newman

monki
Posts: 59
Joined: Tue Dec 13, 2011 10:56 pm

Re: Delete Group via script

Post by monki » Thu Mar 02, 2017 9:40 pm

Ok, I see. I'm having a different problem then I thought. I'm asking a group to delete itself. Even tho the actual delete script is at stack level, it's being called by the object to be deleted. The script is blocking itself with an execution error:
...object's script is executing near button "deleteSequence" of Group...
I tried dispatching the command call rather than directly, using the command's name, but the same error. Is there some other way to accomplish this?

LiveCode_Panos
Livecode Staff Member
Livecode Staff Member
Posts: 864
Joined: Fri Feb 06, 2015 4:03 pm

Re: Delete Group via script

Post by LiveCode_Panos » Thu Mar 02, 2017 9:59 pm

Hi Monki,

I have tried this in LC 8.1.3 and it works:

- Card with one grouped button
- Script of button:

Code: Select all

on mouseUp
   send "deleteThisGroup" to card 1 in 10 milliseconds
end mouseUp
- Script of card:

Code: Select all

on deleteThisGroup
   delete grp 1
end deleteThisGroup
Best,
Panos
--

monki
Posts: 59
Joined: Tue Dec 13, 2011 10:56 pm

Re: Delete Group via script

Post by monki » Thu Mar 02, 2017 10:26 pm

That was the answer, thanks Panos :D

Post Reply