HISE Logo Forum
    • Categories
    • Register
    • Login

    Hide Combo Box Menu Item

    Scheduled Pinned Locked Moved Feature Requests
    3 Posts 2 Posters 948 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.
    • d.healeyD
      d.healey
      last edited by

      Could we have a feature to hide a menu item (if we don't already). I can currently think of two uses for this:

      • Adjusting one control on a UI changes the displayed options in a menu.
      • All of your menu items are numbers and you want them to correspond to the getValue() number but you don't want to start from 0 or you want to skip values.

      To clarify the second use case a bit more lets say you want a menu that contains CC numbers 1 - 100 but missing out 64, so I'd do something like this:-

      var menuItems = [];
      
      for (i = 1; i < 100; i++)
      {
      	if (i == 64) continue
      	menuItems[i] = i;
      }
      
      menuItems = menuItems.join("\n");
      myComboBox.set("items", menuItems);
      

      The problem is I will end up with a menu items string like this

      undefined/n1/n2/n3/n4/n5/n6/n7/n8/n9/n10/n11/n12/n13/n14/n15/n16/n17/n18/n19/n20/n21/n22/n23/n24/n25/n26/n27/n28/n29/n30/n31/n32/n33/n34/n35/n36/n37/n38/n39/n40/n41/n42/n43/n44/n45/n46/n47/n48/n49/n50/n51/n52/n53/n54/n55/n56/n57/n58/n59/n60/n61/n62/n63/undefined/n65/n66/n67/n68/n69/n70/n71/n72/n73/n74/n75/n76/n77/n78/n79/n80/n81/n82/n83/n84/n85/n86/n87/n88/n89/n90/n91/n92/n93/n94/n95/n96/n97/n98/n99
      

      I would like to hide the undefined menu items so that the user can't see them but it doesn't affect the order so that when I select option 8 and use getValue() the value will be 8.

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

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

        I can't think of a way to do this without hacking something, but you can use the current text as value:

        var menuItems = [];
        
        for (i = 1; i < 100; i++) menuItems.insert(-1, i);
        menuItems.remove(64);
        
        const var ComboBox = Content.addComboBox("ComboBox", 59, 12);
        
        menuItems = menuItems.join("\n");
        ComboBox.set("items", menuItems);
        
        function onNoteOn() {}
        function onNoteOff() {}
        function onController() {}
        function onTimer() {}
        function onControl(number, value)
        {
        	Console.print(parseInt(ComboBox.getItemText()));
        }
        
        1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey
          last edited by

          Ah that's a good idea!

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

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

          22

          Online

          1.7k

          Users

          11.8k

          Topics

          102.6k

          Posts