Why method are called before panel loading?

Home Forums General Programming Why method are called before panel loading?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #54369
    urbanspaceman
    Participant
      • Topics: 7
      • Replies: 38
      • Total: 45

      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.
      #54388
      zeoka
      Participant
        • Topics: 73
        • Replies: 466
        • Total: 539
        • ★★★

        if 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 that

        #54401
        urbanspaceman
        Participant
          • Topics: 7
          • Replies: 38
          • Total: 45

          in the screenshot, the error
          the method is

          function 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.
          #54428
          zeoka
          Participant
            • Topics: 73
            • Replies: 466
            • Total: 539
            • ★★★

            it’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)

            • This reply was modified 8 years, 9 months ago by zeoka.
            • This reply was modified 8 years, 9 months ago by zeoka.
            • This reply was modified 8 years, 9 months ago by zeoka.
            • This reply was modified 8 years, 9 months ago by zeoka.
            #54440
            dasfaker
            Keymaster
              • Topics: 80
              • Replies: 793
              • Total: 873
              • ★★★

              I 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.

              #54443
              zeoka
              Participant
                • Topics: 73
                • Replies: 466
                • Total: 539
                • ★★★

                normally it would be not needed just to change tabs via several buttons
                urbanspaceman wants to do something with the tabs names I don’t get

                the script I wrote would be correct even better than radio buttons
                normally working at startup

                imo I prefer set modvalue of uiTabs instead of currentTab there is never issue at startup

                #54445
                dasfaker
                Keymaster
                  • Topics: 80
                  • Replies: 793
                  • Total: 873
                  • ★★★

                  imo 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.

                  #54449
                  zeoka
                  Participant
                    • Topics: 73
                    • Replies: 466
                    • Total: 539
                    • ★★★

                    you’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 oO

                    edit2 : yes it is synced

                    • This reply was modified 8 years, 9 months ago by zeoka.
                    • This reply was modified 8 years, 9 months ago by zeoka.
                    #54453
                    dasfaker
                    Keymaster
                      • Topics: 80
                      • Replies: 793
                      • Total: 873
                      • ★★★

                      It’s true, it’s linked.

                    Viewing 9 posts - 1 through 9 (of 9 total)
                    • The forum ‘Programming’ is closed to new topics and replies.
                    There is currently 0 users and 87 guests online
                    No users are currently active
                    Forum Statistics
                    Threads: 2,495, Posts: 17,374, Members: 77,605
                    Most users ever online was 12 on January 22, 2019 3:47 pm
                    Ctrlr