Hi everyone,
I’m trying to add a new main menu item to the editor’s menu bar, and I have a sample script created with the assistance of ChatGPT. However, the menu doesn’t seem to appear or work as expected. Below is the code I’m using:
local M = {}
function M.get_commands()
return {
{
label = "Library", -- Menu name
locations = {"Edit"}, -- Not sure what to put here instead of "Edit"
query = {selection = {type = "resource", cardinality = "one"}},
active = function(opts)
return true -- The menu is always active
end,
subcommands = {
{
label = "New Card",
active = function(opts)
return true -- Logic to determine if "New Card" is active
end,
run = function(opts)
print("New card created!") -- Logic for creating a new card
end
},
{
label = "Collections",
active = function(opts)
return true -- Logic to determine if "Collections" is active
end,
run = function(opts)
print("Collections management opened!") -- Logic for handling collections
end
}
}
}
}
end
return M
Does anyone know if it’s possible to add a custom main menu entry like this, or what might be going wrong with this approach? Also, I’m not sure what the correct value for locations
should be instead of “Edit.”
Thanks in advance for any help!