Forum

    • Register
    • Login
    • Search
    • Categories

    set ComboBox index

    Scripting Forum
    3
    3
    501
    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.
    • Dan Korneff
      Dan Korneff last edited by

      can someone enlighten me on how to set the default index of a Combobox when a plugin is initialized?
      I'm using

      ComboBox2.SelectedIndex = 0;
      

      without any luck. I get an error saying it cannot assign to this expression.

      Dan Korneff - Producer / Mixer / Audio Nerd

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

        @dustbro I imagine you are getting that error because there isn't a "SelectedIndex" property as far as I can see. If you type ComboBox into the API search you will see all of the functions available for that control. The one you want is called setValue() however it seems that even though it sets the value it doesn't update the display, so I'm still trying to figure out that part.

        Edit: I figured it out, you have to call setValue() outside of the on init callback - in the on control callback for example - or you have to set the Save In Preset property for the control to false. This is because after on init is triggered it will overwrite any values you assign with the one saved in the preset.

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

        1 Reply Last reply Reply Quote 1
        • Christoph Hart
          Christoph Hart last edited by

          Yes, that is correct. Be aware that the value starts with 1 (so in order to set it to the first item, call setValue(1);). Zero is reserved for no entry.

          If you use the combobox for a control that's supposed to be stored in a preset (aka saveInPreset = true), you don't need to explicitely call this, just make sure you save the patch with the right value.

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

          12
          Online

          1.1k
          Users

          6.8k
          Topics

          62.5k
          Posts