Forum

    • Register
    • Login
    • Search
    • Categories

    LAF drawToggleButton

    General Questions
    3
    36
    65
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DanH
      DanH last edited by DanH

      I know this has been covered: Using

      if (obj.text == "somename")
      

      to apply the LAF to another button (or group of buttons sharing the same text). But can you apply it to more than one other button / group?

      As in use more if statements in the function. Haven't done it successfully yet.

      Would be really wonderful if we could customise individual / groups of buttons using this LAF feature (imo 😆 )

      d.healey 1 Reply Last reply Reply Quote 0
      • d.healey
        d.healey @DanH last edited by

        @DanH Don't use multiple if statements. Use 2 arrays.

        For example if you wanted to capitalize all of the preset browser buttons you could do something like this:

        var presetBrowserButtons = ["Add", "Rename", "Delete", "Save Preset", "More"];
        var newText = ["ADD", "RENAME", "DELETE", "SAVE PRESET", "MORE"];
        
        if (presetBrowserButtons.contains(obj.text))
            g.drawAlignedText(newText[presetBrowserButtons.indexOf(obj.text)], obj.area, "centred");
        

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        DanH Natan 2 Replies Last reply Reply Quote 0
        • DanH
          DanH @d.healey last edited by

          @d-healey ok thanks, hopefully this will work with obj.id too

          d.healey 1 Reply Last reply Reply Quote 0
          • d.healey
            d.healey @DanH last edited by

            @DanH obj.id isn't usable is will always produce "" if I remember correctly.

            Libre Wave - Freedom respecting instruments and effects
            My Patreon - HISE tutorials
            YouTube Channel - Public HISE tutorials

            DanH 1 Reply Last reply Reply Quote 0
            • DanH
              DanH @d.healey last edited by

              @d-healey Roger that. So is it wrong to use two if statements? Because I'd like to apply this to several arrays !

              d.healey 1 Reply Last reply Reply Quote 0
              • d.healey
                d.healey @DanH last edited by d.healey

                @DanH

                So is it wrong to use two if statements?

                If it works then it's not wrong.

                My suggestion would be to use the two array technique for each group of buttons you want to customise and then use an if statement for each of those groups.

                So it would look something like this:

                if (presetBrowserButtons.contains(obj.text))
                    g.drawAlignedText(newText[presetBrowserButtons.indexOf(obj.text)], obj.area, "centred");
                
                if (anotherArray.contains(obj.text))
                    g.drawAlignedText("I love HISE", obj.area, "centred");
                
                if (oneMoreArray.contains(obj.text))
                    g.drawAlignedText("Watch Dave's YouTube Channel", obj.area, "centred");
                

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

                DanH 2 Replies Last reply Reply Quote 0
                • DanH
                  DanH @d.healey last edited by DanH

                  @d-healey thanks David - so I just tried

                  if (presetBrowserButtonss.contains(obj.id))
                  

                  and it works... worth trying out?

                  (I made an array with the ids in)

                  d.healey 1 Reply Last reply Reply Quote 0
                  • DanH
                    DanH @d.healey last edited by

                    @d-healey Trying to use more than one if statement and the last statement seems to override the others. Close but no cigar just yet!

                    1 Reply Last reply Reply Quote 0
                    • d.healey
                      d.healey @DanH last edited by

                      @DanH What does obj.id return?

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      DanH 1 Reply Last reply Reply Quote 0
                      • DanH
                        DanH @d.healey last edited by

                        @d-healey how can I check?

                        d.healey 1 Reply Last reply Reply Quote 0
                        • d.healey
                          d.healey @DanH last edited by

                          @DanH Console.print()

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          DanH 1 Reply Last reply Reply Quote 0
                          • DanH
                            DanH @d.healey last edited by

                            @d-healey I did try but it crashed, wasn't sure where to put it.

                            d.healey 1 Reply Last reply Reply Quote 0
                            • d.healey
                              d.healey @DanH last edited by

                              @DanH Put it right before you're using it.

                              Libre Wave - Freedom respecting instruments and effects
                              My Patreon - HISE tutorials
                              YouTube Channel - Public HISE tutorials

                              DanH 1 Reply Last reply Reply Quote 0
                              • DanH
                                DanH @d.healey last edited by DanH

                                @d-healey lots of crashes, I made a snippet:

                                HiseSnippet 1605.3oc0YslaaaDDl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GQtrbeJg4qfrfwBQEPJKHG3cCyAJhJqfgTcwzBSknD.Y45PTlC1yrXrmcwXO2hw9FKF64WL1KrXrWbwXuzTX+4aukEyhWFUnuD3e0G4wvbWW0sPGC0mJJpJl1VH+iXz9PMv0n85SIbOOUsYvc6siU46aTd33Nm8xxihiyqq1LWNyrkJVpPQ9pZNTPFYEz8VPAYkTvYCtETPN4UvuJo.ExDJHWlBkLMJTnTt4TAaHo.k2bKnf7xJ3japBRDpfcrfbHAx+NZAsk8gNS1D+9cKySevqtu5yO3f81skt4bIYYmmyvx11tWPxYlPxqNCetGI6lxaJe3jy42j0nX97YxURIpzhfIJXVvHW9LEmucKY+02KasaN3Bqory4Zpnjr+627waMs5LD9RxE6IKnlu3gFgitRcfZVXSddV9g3Cm.R+OwAG4GNj3iYCkOj+sxgbmU3dOslXlc2oi2klBdg.+213M7JCRnUucan1zHvthVie+S78CDdGNeqVSp6v9coDrcCrKb12..ESSzw7JtEGEkFdn+X.hXGsK9m+S4mI6B.a+RIY+gxOafkaztd4S2+eqTE2mBkGOSVjkmsBHulat4pba9dswKJ8EwWe4YyfcMFo6JPpl1NM1K7iPnk9Xbad8.6h1Hk6TleiZaGYJK+Wk+MqiQsod8BKvYL66f5.JRdjCPPfpVCI1xFpV8nTVWLoyj2S28KuCk1uNwBV5NxBoYWKe9wQfSJIKlZC7YzdivRvE40hg5GTWl5K0xmKM7z9m3uKUCdkcuON8+H5nszL5n8cAVxwlLtM8y7HpBDOwmGe1mCfGwR+KlbV+nVXvvfc4ubv8c0d1mAfce5.FDA5oVLOLTdj1tC50BJ2wFA.kPPt7KfPcIdTFQeCd+ffWHhSPm+CdBmzj2WMbRyQSpzyx1i9ZawAM4etemfQ.LQB9kGho8Tde8w2qfllQZCkdXG7qss4I5e.f8oySla.OYuA7j6FvyF2.dxeC3ovMfmhWIO7eDlJCfrJBeSXfl0E4STGmWRcYk+G.eXW9j
                                

                                Using the obj.id changes all the buttons it turns out, and I couldn't get more than one if statement to work 😞

                                d.healey 1 Reply Last reply Reply Quote 0
                                • d.healey
                                  d.healey @DanH last edited by

                                  @DanH obj.id returns undefined parameter. So like I said, don't use it 😛

                                  Libre Wave - Freedom respecting instruments and effects
                                  My Patreon - HISE tutorials
                                  YouTube Channel - Public HISE tutorials

                                  DanH 1 Reply Last reply Reply Quote 0
                                  • DanH
                                    DanH @d.healey last edited by

                                    @d-healey indeed!

                                    Any ideas on how to squeeze a couple more if statements into that snippet?

                                    d.healey 1 Reply Last reply Reply Quote 0
                                    • d.healey
                                      d.healey @DanH last edited by

                                      @DanH Not the way you're doing it. You need to use the text property, or some other property to determine which control you're styling.

                                      Libre Wave - Freedom respecting instruments and effects
                                      My Patreon - HISE tutorials
                                      YouTube Channel - Public HISE tutorials

                                      DanH 1 Reply Last reply Reply Quote 0
                                      • DanH
                                        DanH @d.healey last edited by

                                        @d-healey I understand, yet using obj.text in two statements renders the first invalid

                                        HiseSnippet 1628.3oc2YssaaaCFVJIpH1atncqXX6NgbkMVpqjsiOrfg5CItKn4fabZ2.JFJXjnsYiLomDURMJJPub2sWg8nj2gc8dG5avFonrEsiShOjLjNE.EQx+Cej+eh7W+tgKwB54QbUTicT+dPE0uTqYeLsSsN.DVYmsTTSncrOkRv5TnGUoZ+d.OOnshp5xOiKhZrUTBt9zSqBb.XKXTWJJuhfrf6h5hnQ81n7yQNN0A1viPckjNW4crH3ZDGhOCNKqYnzCXcBnMbe.WrkzTTu211HJwsIEv.ih5JUI18a1gbFVH+qPdnicf7FlJMYFRzcchiMGw7dUp0A4X2Xvz1SgYkFQKBKKVDdj1dHazv9iVLdPv.5QZHudntzUAOSY3YL8vSUBdqHf2C0ZZ4h5QiFgisuPaGLE51BvBAxvRHqxR+8pZ0HLIvzzcAm.q6xZLTij4MLVWeCCiTalHdh3Ogeoquak5555AMdRh3rniGU+TfqtCnk9OpuMtMBCSa4BYy2m4PNF3H70tDxIUv10gPmjB6EoZ0.xjmYEWWPelQd8ZhdLWac8vGyD8X1090Mmf1YFW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DLxpNxgBEEtJllng4UTcQEk5tveyGhshVE+8+p7Kjo.rkeoCY+1xuvG3L1pdUTOBK83oJhr7zk.40TQwqh17MZCmT5KBWe4oKfcMAo6KPpl1t0OH7kP1S5Cws40CrKFiTVsLuRu6DEJK+Gk+YvovVD2tgI3LT8cgsYNRtmifrMpZ1GaIGnZ1kPncP31iV+3GUdWBo21X.apaKajFc.d7OGg8kRxloluGkzc.VBJvbSJrWPdYpuVKetzrqVeO+doZraYO3lo8MHQaoojn80AQxggLdL8N9NpBDOxqG24OCfuik9mMmY8cZgaFFrJ+4Ctuu1KtC.1CI9T1NP6AntHV5QZ662sIKcGKHCnXLzgW.B0k36xHZavaGr4EDaGz3eXWgCZxaqFNn4fAU5BrbIuwR7gl7W2WMnGFlvA+hXwz1i2VeXcEzzLRanzEYidikE+f9Gyv9j0IybnS14PmbygNaLG5jeNzovbnSwqTG9ONXEe1oJBtIqiFaKNOQc34RpKq7urmoU5.
                                        
                                        d.healey 1 Reply Last reply Reply Quote 1
                                        • d.healey
                                          d.healey @DanH last edited by

                                          @DanH ALWAYS USE CURLY BRACES WITH YOUR IF STATEMENTS.

                                          Libre Wave - Freedom respecting instruments and effects
                                          My Patreon - HISE tutorials
                                          YouTube Channel - Public HISE tutorials

                                          DanH 2 Replies Last reply Reply Quote 0
                                          • DanH
                                            DanH @d.healey last edited by

                                            @d-healey Savage 😂

                                            1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post

                                            11
                                            Online

                                            849
                                            Users

                                            5.7k
                                            Topics

                                            52.8k
                                            Posts