Page 1 of 1

Is there a way to create keyboard shortcuts for menu scripts?

Posted: Thu Mar 30, 2023 2:01 pm
by bbrraayyaann
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.

Re: Is there a way to create keyboard shortcuts for menu scripts?

Posted: Thu Mar 30, 2023 11:34 pm
by synthsin75
Yeah, that would be nice.

Re: Is there a way to create keyboard shortcuts for menu scripts?

Posted: Fri Mar 31, 2023 1:21 am
by SimplSam
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.

Re: Is there a way to create keyboard shortcuts for menu scripts?

Posted: Fri Mar 31, 2023 1:51 am
by bbrraayyaann
SimplSam wrote: Fri Mar 31, 2023 1:21 am 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.
haha that would be nice, I'm going to try it.

Re: Is there a way to create keyboard shortcuts for menu scripts?

Posted: Fri Mar 31, 2023 10:56 am
by hayasidist
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:

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
				},
 ...
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????

Re: Is there a way to create keyboard shortcuts for menu scripts?

Posted: Fri Mar 31, 2023 12:32 pm
by bbrraayyaann
hayasidist 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????
I also tried that, but Moho doesn't seem to allow it

Re: Is there a way to create keyboard shortcuts for menu scripts?

Posted: Sat Apr 01, 2023 12:01 am
by synthsin75
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.

Re: Is there a way to create keyboard shortcuts for menu scripts?

Posted: Sat Apr 01, 2023 2:14 pm
by hayasidist
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.