Started using the newly introduced dynamically-generated buttons to enhance my Dynamic TabGroups FAYT script.
I can't seem to manage to display images for submenus.
I do get first level items to get an icon (including the sub-menu), but after that ... no more:
Hi @Jon. Coming back regarding this issue.
I built a much smaller (dummy) example:
Builds a command to test (TestDynMenu) which can accept argument LIST to display a menu
Menu consists of:
1 button with icon (OK)
1 menu with icon (OK)
1 sub-item with icon (Not OK)
1 button with icon (outside of the menu) (OK)
All three buttons are built exactly in the same way (properties set) from a addButtonHelper.
For the value of menu.childimages, I tried "on", "ON", "On", "#on", true, "true", false, "icon", "icons", "#newtab" ... without any success in getting an icon to display for the button in the submenu.
// TestDynamicMenus
// (c) 2025 Stephane
// This is a script for Directory Opus.
// See https://www.gpsoft.com.au/endpoints/redirect.php?page=scripts for development information.
// Called by Directory Opus to initialize the script
function OnInit(initData)
{
initData.name = "TestDynamicMenus";
initData.version = "1.0";
initData.copyright = "(c) 2025 Stephane";
// initData.url = "https://resource.dopus.com/c/buttons-scripts/16";
initData.desc = "";
initData.default_enable = true;
initData.min_version = "13.0";
initData.group = "Test";
}
// Called to add commands to Opus
function OnAddCommands(addCmdData)
{
var cmd = addCmdData.AddCommand();
cmd.name = "TestDynMenu";
cmd.method = "OnTestDynMenu";
cmd.desc = "";
cmd.label = "TestDynMenu";
cmd.template = "LIST/S";
cmd.dynamic_args = "LIST";
cmd.hide = false;
cmd.icon = "script";
}
// Implement the TestDynMenu command
function OnTestDynMenu(scriptCmdData)
{
DOpus.Output("TestDynMenu");
}
function OnAddButtons(addButtonsData) {
// Make sure we're being called because of the LIST argument, otherwise bail.
if (!addButtonsData.args.got_arg.LIST)
return false;
var addButtonHelper = addButtonsData.buttons;
// Simple Item #1
var button = addButtonHelper.AddButton();
button.label = "Test 1";
button.func = 'Set NOOP';
button.image = "#newtab";
button.notablabel = true;
button.desc = "Some desc 1";
// MENU
var menu = addButtonHelper.AddMenu();
menu.label = "Menu";
menu.image = "#folder";
menu.childimages = true;
menu.notablabel = true;
// Item inside Menu
var buttonInMenu = menu.children.AddButton();
buttonInMenu.label = "Test In Menu";
buttonInMenu.func = 'Set NOOP';
buttonInMenu.image = "#newtab";
buttonInMenu.notablabel = true;
buttonInMenu.desc = "Some desc in menu";
// Simple Item #2
var button2 = addButtonHelper.AddButton();
button2.label = "Test2";
button2.func = 'Set NOOP';
button2.image = "#newtab";
button2.notablabel = true;
button2.desc = "Some desc 2";
return true;
}
EDIT: Re-uploaded the script which contained a typo (in one of the tests, I replaced the first button.notablabel property value instead of menu.childimages value).