Is there a way to create keyboard shortcuts for menu scripts?
Moderators: Víctor Paredes, Belgarath, slowtiger
-
- Posts: 69
- Joined: Thu Jan 24, 2019 3:52 am
Is there a way to create keyboard shortcuts for menu scripts?
I would like the script not to appear in the tools section, but at the same time I want a keyboard shortcut to use it when I need it.
- synthsin75
- Posts: 10267
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Is there a way to create keyboard shortcuts for menu scripts?
Yeah, that would be nice.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Re: Is there a way to create keyboard shortcuts for menu scripts?
I guess one trick would be to create Tool buttons with transparent icons... and name them starting with 'zz' so they are at the bottom.
Moho 14.3 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
-
- Posts: 69
- Joined: Thu Jan 24, 2019 3:52 am
- hayasidist
- Posts: 3842
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Is there a way to create keyboard shortcuts for menu scripts?
For any / only tech-heads:
I got a little way into this - maybe someone can pick it up:
-- if you create a set of custom shortcuts (Edit / Edit Keyboard Shortcuts) called (e.g.) test, you get a file test.json in <custom folders>/Keyboard Shortcuts
-- that has a tree structure that mirrors the menu bar and tool panel. Example extract:
the "Key" fields (e,g. from the above) "groupNameKey": "/Menus/File/File" index into the "strings" files (e.g.) Program Files\Moho\Resources\Strings\Strings.EN.txt
(IOW there's a line in the Strings.XX.txt file that is the localisation - such as in Strings.DE.txt: /Menus/File/File=Datei)
I added (manually) a bunch of Group and Action entries for /Menus/Scripts/Scripts and /Menus/Scripts/3D to try things out. The edited test.json "worked" and did show up in the Edit Keyboard Shortcuts tool BUT there were no localisation Key entries for any keys [(e.g.) "actionDescriptionKey": "/Menus/Scripts/3D/Cube"], so the text presented in Edit Keyboard Shortcuts tool was "just" the keyname.
Whilst it was possible to assign a shortcut key to (e.g.) Cube, the keystroke didn't invoke the tool?!
I'm guessing that all the handlers for Menu items (e.g. File / Open / ..) _except_ Script are embedded in Moho core -- Scripts are the only .lua stuff in the Menu line -- and this is the reason behind why the custom keystrokes won't work?
Anyone got any better ideas / info????
I got a little way into this - maybe someone can pick it up:
-- if you create a set of custom shortcuts (Edit / Edit Keyboard Shortcuts) called (e.g.) test, you get a file test.json in <custom folders>/Keyboard Shortcuts
-- that has a tree structure that mirrors the menu bar and tool panel. Example extract:
Code: Select all
{
"group_platform": "",
"group_product": "",
"nodeTypeBranch": true,
"groupNameKey": "/Menus/File/File",
"Bindings": [
{
"modifiers": "cmd-ctrl",
"actionDescriptionKey": "/Menus/File/New",
"boundKey": "N",
"platform": "",
"product": "",
"readonly": false,
"nodeTypeBranch": false
},
...
(IOW there's a line in the Strings.XX.txt file that is the localisation - such as in Strings.DE.txt: /Menus/File/File=Datei)
I added (manually) a bunch of Group and Action entries for /Menus/Scripts/Scripts and /Menus/Scripts/3D to try things out. The edited test.json "worked" and did show up in the Edit Keyboard Shortcuts tool BUT there were no localisation Key entries for any keys [(e.g.) "actionDescriptionKey": "/Menus/Scripts/3D/Cube"], so the text presented in Edit Keyboard Shortcuts tool was "just" the keyname.
Whilst it was possible to assign a shortcut key to (e.g.) Cube, the keystroke didn't invoke the tool?!
I'm guessing that all the handlers for Menu items (e.g. File / Open / ..) _except_ Script are embedded in Moho core -- Scripts are the only .lua stuff in the Menu line -- and this is the reason behind why the custom keystrokes won't work?
Anyone got any better ideas / info????
-
- Posts: 69
- Joined: Thu Jan 24, 2019 3:52 am
Re: Is there a way to create keyboard shortcuts for menu scripts?
I also tried that, but Moho doesn't seem to allow ithayasidist wrote: ↑Fri Mar 31, 2023 10:56 am For any / only tech-heads:
I'm guessing that all the handlers for Menu items (e.g. File / Open / ..) _except_ Script are embedded in Moho core -- Scripts are the only .lua stuff in the Menu line -- and this is the reason behind why the custom keystrokes won't work?
Anyone got any better ideas / info????
- synthsin75
- Posts: 10267
- Joined: Mon Jan 14, 2008 11:20 pm
- Location: Oklahoma
- Contact:
Re: Is there a way to create keyboard shortcuts for menu scripts?
If I were to attempt something in this vein, I'd probably write a single tool script that could have menu scripts and shortcuts assigned from tool option dropdowns.
It would involve more than a single shortcut key through, as you'd have to invoke the tool (manually or by shortcut) and then likely use an Alt+key shortcut within it for each script.
Might be better than constantly digging through the nested scripts menu though.
Personally, I don't put any third-party scripts in folders. That way they're immediately visible when I open the scripts menu.
It would involve more than a single shortcut key through, as you'd have to invoke the tool (manually or by shortcut) and then likely use an Alt+key shortcut within it for each script.
Might be better than constantly digging through the nested scripts menu though.
Personally, I don't put any third-party scripts in folders. That way they're immediately visible when I open the scripts menu.
- Wes
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
Donations: https://www.paypal.com/paypalme/synthsin75 (Thx, everyone.)
https://www.youtube.com/user/synthsin75
Scripting reference: https://mohoscripting.com/
- hayasidist
- Posts: 3842
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Is there a way to create keyboard shortcuts for menu scripts?
I'd followed on from my delve into the relationships between localisation keys, menus and keyboard bindings.
The menu items such as File, Edit, Draw etc ... all use the localisation strings for the menu and KB bindings
BUT
the Scripts menu item doesn't seem to use localisation for the menu items, however the Keyboard bindings DOES use the localisation strings.
So In the edit KB shortcuts, if I add a line for Torus and give it a name that has clearly been taken from the localisation strings (e.g. "ringo"), that's what is seen the the edit KB shortcuts tool, but NOT in the menu
Whereas if I change something such as File/Quit from "Quit" to (e.g.) "I'll be back", that does show up in both menu and edit KB shortcuts tool.
===
Bottom line: the Scripts menu dropdown is very different from the other menu items, and I can't see a way to associate a keystroke to anything that's in there.
The menu items such as File, Edit, Draw etc ... all use the localisation strings for the menu and KB bindings
BUT
the Scripts menu item doesn't seem to use localisation for the menu items, however the Keyboard bindings DOES use the localisation strings.
So In the edit KB shortcuts, if I add a line for Torus and give it a name that has clearly been taken from the localisation strings (e.g. "ringo"), that's what is seen the the edit KB shortcuts tool, but NOT in the menu
Whereas if I change something such as File/Quit from "Quit" to (e.g.) "I'll be back", that does show up in both menu and edit KB shortcuts tool.
===
Bottom line: the Scripts menu dropdown is very different from the other menu items, and I can't see a way to associate a keystroke to anything that's in there.