Script Panel Properties Related with Popup Menu
-
Hello Christoph Hart,
I have tried according to you, but it does not show selected item in menu list.
It just shows following error...Script Processor:! onInit: Line 644, column 16: the property does not existThese are my codes.
const var PanelTemp = Content.addPanel("PanelTemp", 15, 9); // [JSON PanelTemp] Content.setPropertiesFromJSON("PanelTemp", { "width": 161, "height": 31, "allowCallbacks": "Context Menu", "popupMenuItems": "A\nB\nC\nD", "popupOnRightClick": false, "popupMenuAlign": true }); // [/JSON PanelTemp] PanelTemp.setMouseCallback(function(event) { if(event.result) { // the index is zero based, but event.result == zero means no selection so you need to subtract 1 PanelTemp.set("selectedPopupIndex", event.result-1); } });Please let me know why it shows such error.
And PopupMenu::addSeparator() is just what I want. And also I want to add the feature to enable/disable menu item in popup menu list.Thanks for your support.
-
My HISE version is 0.99 and build version of it is 647.
I think you can easily add the feature of separator, something like using "-" as the separator string in the string list.
-
Are you using the most recent version on GitHub? I just added this feature a few days ago.
And I'll add separators and deactivated items.
I propose using___(three underscores) as separator string and~~deactivated Item~~for deactivated items (that's strikethrough in Markdown).I don't know if you need it but you can already make nested popup menus with the syntax
SubMenu::Item -
Didn't read your last post. Let me know if you need a current build (also which OS you are working on).
-
Yes, I knew how to add SubMenu as well. I found such codes in GitHub sources. And I am just using most recent version on GitHub and also HISE standalone as well.
I prefer to know how to build HISE standalone with sources of GitHub repository.
Otherwise, I will be appreciate if you provide me recent Win8.1 x64 and macOS Sierra builds.
Thanks a lot. -
There are build instructions in the GitHub Readme
-
Alright, I pushed these changes to GitHub. You can now do this:
const var Panel = Content.addPanel("Panel", 55, 0); // [JSON Panel] Content.setPropertiesFromJSON("Panel", { "width": 153, "height": 30, "allowCallbacks": "Context Menu", "popupMenuItems": "**This is a header**\n___\nA\nB\n~~Not active~~\nC", "popupOnRightClick": 0, "popupMenuAlign": 1 }); // [/JSON Panel]I also added the section headers - just use the Markdown Syntax for
**bold**. Be aware that Section Headers and Separators don't have an index (deactivated items still do). -
This is a small helper function that deactivates items in a ScriptPanel:
/** Deactivates an item in a custom popup. */ inline function deactivatePopupItem(widget, index, isDeactivated) { local list = widget.get("popupMenuItems").split("\n"); if(isDeactivated) { if(list[index].indexOf("~~") != -1) return; list[index] = "~~" + list[index] + "~~"; } else { list[index] = list[index].replace("~~", ""); } widget.set("popupMenuItems", list.join("\n")); } deactivatePopupItem(Panel, 1, true); -
Those are really nice and easy to implement. Now I made a nice popup menu by using above stuffs.
Many appreciate, Christoph! -
I also added the section headers - just use the Markdown Syntax for **bold**. Be aware that Section Headers and Separators don't have an index (deactivated items still do).I have added Section Header with bold but it is having an index. Would you check and fix it?

-
Yeah I'll take a look.