HISE Logo Forum
    • Categories
    • Register
    • Login

    "contains" as part of a switch statement

    Scheduled Pinned Locked Moved Scripting
    4 Posts 2 Posters 60 Views
    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.
    • Oli UllmannO
      Oli Ullmann
      last edited by

      Hello to all :-)

      I would like to style my buttons with a single LookAndFeel object.

      To determine which text is displayed, I can check the following:

      if(obj.text.contains(“someText”)
          g.drawText(“Text to draw”, area);
      

      Is there a way to do this with a switch statement so that I don't have to write a separate if statement for each text?

      The button text is already used elsewhere in the script, which is why I cannot change it afterwards and then use it as text for drawing.

      Thank you very much
      Oli

      Christoph HartC 1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart @Oli Ullmann
        last edited by

        @Oli-Ullmann use the button text as the key in a JSON object with the display string as value then you don‘t need to branch at all.

        Oli UllmannO 1 Reply Last reply Reply Quote 1
        • Oli UllmannO
          Oli Ullmann @Christoph Hart
          last edited by

          @Christoph-Hart
          Many thanks for the answer! What do you mean by “button text”? The ID?

          Christoph HartC 1 Reply Last reply Reply Quote 0
          • Christoph HartC
            Christoph Hart @Oli Ullmann
            last edited by

            @Oli-Ullmann obj.text

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

            57

            Online

            1.7k

            Users

            11.7k

            Topics

            101.8k

            Posts