Home › Forums › General › Programming › Set Layer Visibility via Combo Box
- This topic has 13 replies, 4 voices, and was last updated 10 years, 8 months ago by auricle.
-
AuthorPosts
-
August 19, 2013 at 4:13 pm #12107
Hello all,
I’m totally new to programming and I’m trying to wrap my head around layer visibility to work for a panel I’m working on.
I want to use a combo box to show/hide layers. So, if the first option is selected layer 1 is shown and the others hidden, if the second is selected then layer 2 is shown and the others hidden.
Can anyone give me any ideas how to do this?
Thank you.
August 19, 2013 at 5:10 pm #12108I’m not remember the exact command in my head but for the “logic” :
combval = Panel:getModulatorByName(“mycombno”):getModulatorValue
mylayer1 = (the defintion i don’t remember,someting with “canvas” a property of the panel )
mylayer2 = same thing
mylayer3 = etc…..
if comval == 1 then
mylayer1:setPropertyInt(“layerVisibility”,1) (the difinition may be not exact)
else
mylayer1:setPropertyInt(“layerVisibility”,0)
end
if comval == 2 then
mylayer2:setPropertyInt(“layerVisibility”,1) (the difinition may be not exact)
else
mylayer2:setPropertyInt(“layerVisibility”,0)
endEtc….
You must separate the condition in several ,instead of make 1 condition :
if blah
elseif blah
elseif blah
endSee some panels to get the exact command or someoneelse will gives here
Hope this helps a little…..
August 19, 2013 at 5:32 pm #12112there is a demo panel that illustrates this
August 20, 2013 at 8:09 am #12137Thanks for your help, guys.
Atom – I checked out the demo panel but the layers are switched from checkboxes not a combo boxes. The function used in the example relies on the component name – layerBlue, layerRed, etc to determine which layer to set visibility. I am not experienced enough to adapt this code to a combo box where I would need to change visibility depending on the value selected within the combo box.
August 20, 2013 at 9:39 am #12141I’ll modify the demo to include combo boxes.
August 20, 2013 at 9:45 am #12142Thanks Atom. I’d greatly appreciate that.
August 20, 2013 at 8:29 pm #12161I updated it in the SVN repo, here is the copy.
Attachments:
You must be logged in to view attached files.August 20, 2013 at 9:24 pm #12163Hi. I am still trying to learn whatever I can about ctrlr, so I downloaded this demo. What does this mean: “To see the layers demo make this layer invisible and make the layer ‘Layers Demo’ visible” and where does someone do that–making layers visible and invisible?
I see that you can select the Current tab by the combo box, by tabs themselves, or by the slider. That seems to be useful. Can different tabs have different devices assigned to them?
Thanks.
Steve
August 20, 2013 at 11:30 pm #12167There is a space in the tab property “Called when the current tab in an uiTabs component is changed” where you can create a midi message by lua (it changes a label in the demo) when the current tab change…
Whatever you change the tabs by slider or tab or combo it will send a midi message for exampleAugust 21, 2013 at 10:26 am #12186I updated it in the SVN repo, here is the copy.
Thank you kindly, Atom. That’s perfect.
Just out of interest. Is it possible to use this ‘is component visible’ property of a Modulator to hide/show modulators instead of using layers?
August 21, 2013 at 11:01 am #12189You can use the property, or you can just set the visibility flag directly
c = panel:getModulatorByName("blah"):getComponent() c:setVisible (true) -- visible c:setVisible (false) -- invisible
August 21, 2013 at 3:07 pm #12201Well I’m stuck. I can’t get it to work – I must be missing something. Would someone please take a look and tell me where I’m going wrong?
There are three layers. The Base layer which is static and two other layers which should be switched depending on whether ID 1 or 2 is selected (ID 0 should switch them both off). The combo box with the script is called Osc1Mode.
Any help would be great.
Attachments:
You must be logged in to view attached files.August 21, 2013 at 4:08 pm #12205I fixed it for you, you had some type-os and most important stuff, if you rename your modulators (and you did rename the combo that switches the layers) you need to remember that in the code, if you reference something by name
panel:getCombo(NAME)
the NAME is the actual name of the combo you want to fetch
Attachments:
You must be logged in to view attached files.August 21, 2013 at 4:20 pm #12207Thank you very much, Atom! I greatly appreciate it.
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.