Clone control

Questions and information about using Lua scripting with Storyboard

Moderator: jamiev

Clone control

Postby atinir » Fri Aug 19, 2016 12:31 pm

Hi :)
I am using gre.clone_control to create dynamically controls. When I call it inside a another function it does not work, but when I call it outside it does work. I don't understand why?

function showcontrol()

gre.clone_control("Oldcontrol","Newcontrol","Layer",data)

end

If someone can help me. Thank you a lot.
atinir
 
Posts: 25
Joined: Thu Apr 21, 2016 9:20 am

Re: Clone control

Postby JohnW » Fri Aug 19, 2016 12:55 pm

Hi Atinir,

Each new control needs to have a unique name and may be why you are having an issue with it. I've also noticed that you've named this function "showcontrol" If your intention is to hide and show a control, this is not a good way to do it. Instead consider using the control's grd_hidden attribute.

-John
User avatar
JohnW
 
Posts: 56
Joined: Wed May 08, 2013 4:52 pm

Re: Clone control

Postby atinir » Mon Aug 22, 2016 6:29 am

Hi John,

Thank you for the reply. You really helped me, I just realized that the name of the old control and the name of the layer was identical, that's why didn't work. After changing the name,it works fine.

Thank you so much, all the best for you ;)

ps: The reason why I am using gre.clone_control, is because I want to delete my controls.
gre.delete_control works only with controls that are dynamically created with gre.clone_control.

Atinir
atinir
 
Posts: 25
Joined: Thu Apr 21, 2016 9:20 am

Re: Clone control

Postby JohnW » Tue Aug 23, 2016 6:57 am

That's great to hear! Keep in mind that you can clone the same control many times on the same layer but the control name itself needs to be different. I find it useful to add all the control names to a table to keep track of them.
User avatar
JohnW
 
Posts: 56
Joined: Wed May 08, 2013 4:52 pm


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 2 guests

cron