I am experimenting with the 'Confiugure Menu' plugin and have a few questions.
(1) I wish to add a new 'File' menu item for the action 'file: open file, in text viewer' from the 'Help / Command palette...' dialog. How would I define this item in JSON? I need a cmd_... keyword that isn't obvious.
(2) Other menus do not use JSON blocks, but configure automatically: 'Macros' and 'Tools' and then 'Plugins' in a slightly different (but still automatic) manner. Can I add my own items to such menus, and if so, how?
(3) What is the JSON syntax for a grayed-out menu divider with text? From the default 'View' menu, I thought "cmd":"0" was the way, but that method does not work for me. Does the number of hyphen characters surrounding the text matter?
Thanks!
Configure Menu Plugin JSON Questions
-
- Posts: 2381
- Joined: 25.08.2021 18:15
Re: Configure Menu Plugin JSON Questions
(1) in such cases, open file py/cudatext_cmd.py. it has ALL Cud command names. search for 'textviewer', item found.
(2) you cannot add own items in such menus, sorry.
(3) that 2 items in the View menu are just 2 disabled items with cmd==0. number of hyphens don't matter. maybe you need to tweak the ConfigMenu to disable menuitems?
API actions for menu_proc() are
MENU_SET_CAPTION
MENU_SET_VISIBLE
MENU_SET_ENABLED # !
MENU_SET_CHECKED
MENU_SET_RADIOITEM
MENU_SET_HOTKEY
(2) you cannot add own items in such menus, sorry.
(3) that 2 items in the View menu are just 2 disabled items with cmd==0. number of hyphens don't matter. maybe you need to tweak the ConfigMenu to disable menuitems?
API actions for menu_proc() are
MENU_SET_CAPTION
MENU_SET_VISIBLE
MENU_SET_ENABLED # !
MENU_SET_CHECKED
MENU_SET_RADIOITEM
MENU_SET_HOTKEY
-
- Posts: 2381
- Joined: 25.08.2021 18:15
Re: Configure Menu Plugin JSON Questions
(3) I fixed the plugin. now 2 disabled menuitems are added (they must be in menu.json and they must start with '--' and end with '--', not other hyphen chars).
Code: Select all
# Support two View disabled menu items
if (cmd_s=='0') and cap.startswith('--') and cap.endswith('--'):
temp_id = app.menu_proc(prnt_id, app.MENU_ADD, command=0, caption=cap)
app.menu_proc(temp_id, app.MENU_SET_ENABLED, command=False)
continue
-
- Posts: 52
- Joined: 13.07.2024 21:19
Re: Configure Menu Plugin JSON Questions
OK, thanks for the details and fixes. Concerning question (2), the 'Command palette...' item seems misplaced in 'Help' because it is not an info display. I wish I could merge 'Command palette...' and 'Macros' and 'Tools' into one menu, maybe 'Programs' (I know this idea is not presently possible).