ComboBox Sub Categories



  • @Natan

    inline function onPanel1Control(component, value)
    {
        local t = component.get("popupMenuItems").split("\n");
        Console.print(trace(t));
        Label1.set("text", t[value - 1]);
    };
    


  • @ulrik said in ComboBox Sub Categories:

    inline function onPanel1Control(component, value)
    {
    local t = component.get("popupMenuItems").split("\n");
    Console.print(trace(t));
    Label1.set("text", t[value - 1]);
    };

    Thank you Ulrick 🙂
    So What is The Trick To Not Including The Sub Menu's Name, Just The Item1/Item2/Item3...?

    Thank You Works Like A Charm, And Thanks To @d-healey I Didnt Figure It Out Until Ulrick Sent The Code Again 🙂



  • @Natan If you don't want to include the submenu name

    inline function onPanel1Control(component, value)
    {
        local array = component.get("popupMenuItems").split("\n");
        local t = array[value - 1];
        //  Without submenu name
        local t2 = t.substring(t.indexOf(":") + 2, 20);
        
        Label1.set("text", t2);
    };
    


  • @ulrik said in ComboBox Sub Categories:

    local array = component.get("popupMenuItems").split("\n");
    local t = array[value - 1];
    //  Without submenu name
    local t2 = t.substring(t.indexOf(":") + 2, 20);
    
    Label1.set("text", t2);
    

    YOU ROCK 🙂 👍 👏 😛



  • @Natan actually this is better, it will follow the length of your "item names"

    local array = component.get("popupMenuItems").split("\n");
    local t = array[value - 1];
    //  Without submenu name
    local t2 = t.substring(t.indexOf(":") + 2, t.length);
    
    Label1.set("text", t2);
    


  • @ulrik Have You Noticed, If You Dont Click On The Menu When Its Open, It Will Show Some Errors?

    Interface:! Line 2705, column 27: Unknown function 'substring'
    

    Just Click On Panel, Once The Drop Down Shows Up, Click On Outside of The Panel



  • This post is deleted!


  • @ulrik
    And Here you Can Clearly See That It Goes To Zero, If You Select Nothing:
    It Goes To Zero, And Shows The Error:

    HiseSnippet 1243.3ocsW01aaaCDlJIpq1atXEXebefvexAK001IoaHCCyMNIatsIwntqc.qCEzRzVDghTShJIFEAX+z1OoAre.aGIkrjUdYEFHNANfO2K7g2c73kQwROZRhLF4T6MyinHmuvc7bgJXP.gIPCO.47H2iIIJZL1Bs+7HRRB0G43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B2xt83RtsuWeS6W.3A9YSFXa9pQvYHK2qSS+x85PK2T.47GtUZMWuRm4Jq2tx5cprd25U5JWYcOz0ZjBQZGMyWt8qF0.e8LRdnybKJKzYuQUJz8m+boP2ecVecHPm4rj.c8wAfgRj9obhZ4IUzimkI.tprzHA5m8EIL07xiucuL9xmJcer6HlxK3l46Z2.egqG227MaXvFtGNcJ7hVAY2v8ne89exOzqg2vfWnNl.OTAkGtmjFNFlM1iBLQ.22zsybVSWnYW2IudbLU3aV7uvmLgcyKK0B6lKDER7hkevy1tROt4CMH.mDlotqAi+CqwK5S451ocGTHLE7G77zghm.b+lso2JXy1qfM6rB1r6JXyyVAa91Uvlu6NsQ+Of77TkLzdMA.Fcn48BGmCEDnJyTQh9O.MJF1IA
    


  • @Natan it's because if the value = 0, then value - 1 will be -1 and you can't take the "substring"

    Try this:

    inline function onPanel1Control(component, value)
    {
        if (value)
        {
            local array = component.get("popupMenuItems").split("\n");
            local t = array[value - 1];
            //  Without submenu name
            local t2 = t.substring(t.indexOf(":") + 2, t.length);
            Label1.set("text", t2);
            Console.print("Selected Item ID: " + value);
        }
    };
    
    Content.getComponent("Panel1").setControlCallback(onPanel1Control);
    


  • @ulrik said in ComboBox Sub Categories:

    @Natan it's because if the value = 0, then value - 1 will be -1 and you can't take the "substring"

    Try this:

    inline function onPanel1Control(component, value)
    {
        if (value)
        {
            local array = component.get("popupMenuItems").split("\n");
            local t = array[value - 1];
            //  Without submenu name
            local t2 = t.substring(t.indexOf(":") + 2, t.length);
            Label1.set("text", t2);
            Console.print("Selected Item ID: " + value);
        }
    };
    
    Content.getComponent("Panel1").setControlCallback(onPanel1Control);
    

    EXCELLENT 👏 👏 👏


Log in to reply
 

18
Online

1.3k
Users

4.1k
Topics

36.3k
Posts