Home › Forums › General › Programming › Why method are called before panel loading?
- This topic has 8 replies, 3 voices, and was last updated 8 years, 9 months ago by dasfaker.
-
AuthorPosts
-
August 7, 2015 at 3:17 am #54369
When i start my panel, i have a lua error
the error is given by the execution of the only method i have for now
this method is common to all buttons on the panel, this buttons only switch the tabs in the panel.After the error, i re-compile the method and work perfectly.
- This topic was modified 8 years, 9 months ago by urbanspaceman.
August 7, 2015 at 10:42 am #54388if you let here the error message we could try to say what happens
generally “if ? ~= nil then” solve error”
the scripts are read in an order when loading you have to always keep in mind thatAugust 7, 2015 at 2:31 pm #54401in the screenshot, the error
the method isfunction viewSwitch(mod, value) local val = mod:getProperty("modulatorCustomIndex") local name = mod:getProperty("modulatorCustomNameGroup") panel:getModulatorByName(name):getComponent():setProperty ("uiTabsCurrentTab", val, false) end
Attachments:
You must be logged in to view attached files.August 7, 2015 at 5:45 pm #54428it’s seems strange what you do with the modulator Name (uiTabs component)
I don’t understand , you want to get each tabs names ?
-- -- Called when any modulator changes on the panel -- -- @program modulator that changed -- @value new modulator value -- klm = function(--[[ CtrlrModulator --]] modulator, --[[ number --]] value) end local curmod = modulator:getProperty("modulatorCustomIndex") if curmod >= 100 and curmod <= 102 then if value == 1 then panel:getModulatorByName("mytabmodulatorName")setModulatorValue ( curmod - 100 , false, false, false) modulator:getComponent():setProperty("componentDisabled",1,false) for f = 100,102 do h = panel:getModulatorWithProperty("modulatorCustomIndex",f):getValue() if curmod ~= f then if h == 1 then panel:getModulatorWithProperty("modulatorCustomIndex",f):setModulatorValue(0,false,false,false) panel:getModulatorWithProperty("modulatorCustomIndex",f): :getComponent():setProperty("componentDisabled",0,false) end end end end end final end
another method that update button states and keep the button ON state if pushed
change your custom index to 100,101,102 (here for 3 buttons)
because by default there is 0 for all modulators
and apply this method to the right place in the property panel
not tested…note: if you want to try , your button values must be set all off before apply the method .don’t forget to remove old method from buttons especially if you want to delete it (ctrlr crash possible)
August 7, 2015 at 9:16 pm #54440I always set a variable on “panel has finished loading” method, and in any other method I check if this variable is on. This way, methods are never executed until “panel has finished loading” is executed.
August 7, 2015 at 9:35 pm #54443normally it would be not needed just to change tabs via several buttons
urbanspaceman wants to do something with the tabs names I don’t getthe script I wrote would be correct even better than radio buttons
normally working at startupimo I prefer set modvalue of uiTabs instead of currentTab there is never issue at startup
August 7, 2015 at 9:57 pm #54445imo I prefer set modvalue of uiTabs instead of currentTab there is never issue at startup
But to do this, you have to change tab inside method “called when modulator value changes” with setProperty (“uiTabsCurrentTab”, n), so at the end it’s the same.
I think he just want to change tab when he press a button.
Anyway, the best way to work with radio buttons is to replace all the buttons with a uiCustomComponent, this way there is just one modulator and you avoid the problems I’ve encountered related to radio buttons.
August 7, 2015 at 10:14 pm #54449you’re right customcomp is ideal but not for beginner
for the value vs currenttab it’s seems this is not the same : currentTab is a child-like of the modulator value ; set the value of uiTabs seems better for startup because currentTab get now a “solid” state…
urbanspaceman I see in other post that you don’t set uiButtonIsToogle On . you could do that it is mainly better
edit
“But to do this, you have to change tab inside method “called when modulator value changes” with setProperty (“uiTabsCurrentTab”, n), so at the end it’s the same.”
no it is synced afaik . hmm have a doubt now oOedit2 : yes it is synced
August 7, 2015 at 10:28 pm #54453It’s true, it’s linked.
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.