Page 1 of 1

Group deleting itself via script (answered)

Posted: Thu Mar 02, 2017 8:12 pm
by monki
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

Re: Delete Group via script

Posted: Thu Mar 02, 2017 8:40 pm
by dunbarx
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

Re: Delete Group via script

Posted: Thu Mar 02, 2017 9:40 pm
by monki
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?

Re: Delete Group via script

Posted: Thu Mar 02, 2017 9:59 pm
by LiveCode_Panos
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
--

Re: Delete Group via script

Posted: Thu Mar 02, 2017 10:26 pm
by monki
That was the answer, thanks Panos :D