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

General Moho topics.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
bbrraayyaann
Posts: 69
Joined: Thu Jan 24, 2019 3:52 am

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

Post 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.
User avatar
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?

Post by synthsin75 »

Yeah, that would be nice.
User avatar
SimplSam
Posts: 1218
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

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

Post 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.
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
bbrraayyaann
Posts: 69
Joined: Thu Jan 24, 2019 3:52 am

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

Post 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.
User avatar
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?

Post 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????
bbrraayyaann
Posts: 69
Joined: Thu Jan 24, 2019 3:52 am

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

Post 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
User avatar
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?

Post 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.
User avatar
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?

Post 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.
Post Reply