Menu & Sub-Menu
-
Can I do a Menu and a Sub-Menu?
Ex: PIANO
- Piano AC
- Piano AC 2
- Piano AC 3
GUITAR
- Guitar 1
- Guitar 2
- Guitar 3Ect?
-
I wonder if you can do this in a combo box?
-
Combobox can't do it, but if you use a ScriptPanel, you can use a special syntax to create advanced popup menus:
Content.makeFrontInterface(600, 500); const var Panel1 = Content.addPanel("Panel1", 0, 0); // Enable popup menus Panel1.set("allowCallbacks", "Context Menu"); // Align the menu to the panel width (nicer) Panel1.set("popupMenuAlign", true); /** This function returns the correct string for the popup item result. * * Headers & separators do not have a result, so there is no 1:1 correlation * between the array index and the result. This function skips headers & separators * (and also removes the submenu name if desired).; * * Arguments: * - array: the popup item list. * - value: the item result. Just pass in the value from Panel.getValue(). * - removeSub: removes the submenu name and only displays the item string. */ inline function getPopupmenuItemText(array, value, removeSub) { if(value == 0) return ""; local i = 0; local index = value - 1; for(element in array) { if(element.indexOf("**") != -1) continue; if(element.indexOf("___") != -1) continue; if(index == i) { // Remove the menu name if(removeSub && element.indexOf("::") != -1) return element.split("::")[2]; else return element; } i++; } return ""; } Panel1.data.items = [ "Menu 1::**FirstHeader**", // Use MenuName::MenuItem syntax for submenus "Menu 1::FirstFirst Item", "Menu 1::~~Deactivated~~", // ~~Name~~ creates a deactivated item "Menu 2::**SecondHeader**", // **Name** creates a bold (unclickable) section header "Menu 2::___", // ___ creates a seperator line "Menu 2::FirstSecond Item", "Menu 2::SecondSecond Item", "Hidden Item" // Top level items will be hidden if you use sub menus ]; // Makes a string from the array const var itemString = Panel1.data.items.join("\n"); Panel1.set("popupMenuItems", itemString); Panel1.setPaintRoutine(function(g) { g.fillAll(Colours.darkgreen); g.setColour(Colours.white); // Can't help myself... g.setFont("Comic Sans MS", 16.0); var text = getPopupmenuItemText(this.data.items, this.getValue()); g.drawAlignedText(text, [0, 0, this.getWidth(), this.getHeight()], "centred"); }); Panel1.setMouseCallback(function(event) { this.setValue(event.result); this.repaint(); });
The
getPopupmenuItemText()
function is necessary because the result ID does not match the indexes - you don't need to understand what's going on in there, just reuse it :) -
is giving me this error
-
@jay You've only given it two parameters, the function definition requires 3. Seems pretty self explanatory to me.
inline function getPopupmenuItemText(array, value, removeSub)
-
@d-healey Yeah, but I didn't do the example @Christoph-Hart did
-
@jay You'll need to post your definition for that function. But whichever version your using the error is telling you it wants 3 parameters and you've only given it 2.
-
@d-healey Is there any way that I can use this menu&submenu script to load instruments out of the sampler?
-
@jay I haven't tried the code but it's just a menu so you can get it to do anything a menu can do, including loading sample maps.
-
@d-healey Let's say I want to connect it like this snippet down here, Can you show me how to do it please?
HiseSnippet 2932.3oc6aEtaabbD9njOWqqQI1A4G8Gs.aIZcIkknHoUrcjfQjDEsMSLkHDkcBfqgwp6VRtwGukX26jDqgE5qR+W+YeD5CPA5iPeExaP5r6dGu8jHoDscZBREgivc6Nybe6NyNy2tKRKNykHDLtUtENX3.hUtOxt8vfvd05goAVM1wJ2Ga2DKBIbjtosGN.KDDOqb4l+wxFxsv0rT+99ubarONvkj1jk0yYTWxSo8ogos1Zyul56+HrG4.ZeCoWayFtrfZLeVDfm4sKaM.69ZbWxtXoXyYak6508ngLd6PbHQXk6Zay7F1tG63.s7OmJnG5SjuTwpMXHcyOh46IQr7YqZ8n9dsRF2BKvnsRmElWOK7Y1ModzQsmNabSUGnTMLmOxM2zfWk2Q3ky.dWSCuaY21kSGDl1iDa+Z6FAfipCFbAlvRKq0b+qO0d0kVB8j8ZVuYiuswtOF0X21Gr+yZVe2CZiVZoEcj+CgPaEfHmf6OvmfFvYeGwMDE1CGhDvPQ.ORPQBvsfXcPOoQ65nNLNBGfZDHB4Q8IAgkzlZoUWzYQmZL.UPa8wul7HN7xHTVnRk6UdYz8te4haHkb0UQO7C1uUW8hMHpEZeTcTa3+N.966uAmU.dYfHmHHgns4vbOrJ7hsIrFRDhNByQ8gn11J+HnGRsttTWRXbSExG+Pd4repV05entil3AfZItOrmWMV+CYayNoPdSYxuL59U9hkQOn3FHS6HTBzGOP.V4E4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jcOppfQi8nZkcOlRk.crxVpyZtOABGGC8MmIyCyY5bvblF+KmIv8xYbbobL3B4bQLZbtH1LNSlIiiAEFK0t1kyV+cX5pmpBl7s0T2Py4twgaZ2j4E4K4dYdYHxa.JtCHmclacPdJ+ABZ3PyrTyvMjTdr2PxXSIeIg6sraQCc6Md7N2XvqLG+Ox3M99lVztdmN.E4TvdM6G8suqWtz6FT9cZn7o1PnLA2GhliO.TEdVvN4sO.2.3fK8M.1hS7YXu1z+hgX+yM2NBlt3Ya8ero5SsUeVTPluULv2G17.Fnf4kAd6u+i4rnAmUqu+KUwJGv0Y4L6Xu.BLsGZZjZblPzAFNJaIL6pUDuqbtx3KBL53hrssaTev0G.I.EIIvfcSJc0T2lXH0xIlRq9JkO.qb2+Q6pqUJ6ui1C9Sm6He7KpodWqRkYWkpytJ2c1UYsYWkOe1U4dytJ2elTIkfj5xpsytf8Wc4HnBpqpDZH41ztFlV1R17tFhNJRTAbiqF+mI268G9r5u+Egl+xA2K3p4WHAisoRWU8fifLWPK5JO6P5fgMvMpUSP1jEvFziEPcyll.V12sKgaB8wNd1JLDxRk1xms49DeBVXjm6Or4Sg8wi4Yy9MSSEUt7SESyc8ar0vEIy7i9kA2g4++dtCSap6iiYNH4fxC+Yte9irU48QRtI+TAU8ot0MotuMPNnMPHxkXRQXNIsC86kkuKATaRfm5ke.9E2YkD9DxNqjzokahofwV7ypiOH27D0MFpnDqNKSyPZAP6RBIn5l0n6SFF1xYNns13iH5LLZ7LQtUMotsXvjIrNRlzwdiYfHpSBQzp+BhI5l+v+YyqXhdESzqXhdESzqXhdESzqXhdESzqXh9SCSz+WLn6ic4rW4pu4O4P+FpV.DDn9+0gEraJeGUI4h9jNq9PcuW45JWUsREKqwqQ0YVi6NyZr1LqwmOyZbuYVi6OyZ7fongjjwVQgr95brPCspqiKyUeTb47V+W.zw7zDB
-
This post is deleted! -
It seems like you can get the menu text so you just need to use that text to load a sample map with the
Sampler.loadSampleMap()
function. -
@d-healey in this particular scenario how so I do it?
-
@jay I don't have time at the moment to study your code. Can you get the text from the menu?
-
@Christoph-Hart Is there any way that I can use this menu&submenu script to load instruments(selection) out of a sampler?
-
@Christoph-Hart This is so cool!
-
Hmm... Mysteriously this has stopped working somehow... The panel is there, the script goes through and I've set the 3rd parameter of the inline function getPopupmenuItemText (removeSub) to true but when I click on the panel it doesn't show or react anyhow... Funny thing since it's been working just now...
-
@UrsBollhalder Right click ;)