Inject Script Action into Existing Menu: Possible?

User avatar
intelligent machine
Fusionista
Posts: 427
Joined: Fri May 13, 2016 10:01 pm
Answers: 2
Location: Austin, Texas, USA
Been thanked: 32 times
Contact:

Inject Script Action into Existing Menu: Possible?

#1

Post by intelligent machine » Sat May 18, 2019 1:48 pm

Is it possible to write a config that will inject a new script action into an existing menu?
Say I want to add an "archive" or my "Incremental Save" script to the Fusion "File" menu in a specific place within that menu.

I can already create a new top level menu no problem.
The menu entry in the .fu file looks something like this currently:

Code: Select all

	{
		Target = "ChildFrame",
		
	Before "Help" 
	{
		Sub "MyMenu"
		{
			"Incremental_Save{}",
			"_",
			"Branch{}",
			"Merge{}",
			"_",
			"Archive{}",
		},
	},
},

I tried making "MyMenu" and just the menu items subs of "File" instead, but that doesn't work.
Any ideas?


User avatar
SecondMan
Site Admin
Posts: 3582
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 5
Location: Vancouver, Canada
Been thanked: 104 times
Contact:

Re: Inject Script Action into Existing Menu: Possible?

#2

Post by SecondMan » Sat May 18, 2019 7:38 pm

Possible! :)

There are several Atoms in Reactor that make use of that functionality and can serve as an example. From the top of my head, Restart Fusion, Forum Utilities and nuke2fusion all do menu adding/adjusting.

Here's an example that adds an Incremental Save entry to the File menu:

Code: Select all

{
	Action
	{
		ID = "Incremental_Save",
		Category = "File",
		Name = "Incremental Save",

	Targets =
	{
		Composition =
		{
			Execute = [=[print("Saving a little bit more than before...")]=],
		},
	},
},
Menus
{
	Target = "ChildFrame",

	After "File\\Save Version"
	{
		"Incremental_Save{}",
	},
},
}

For others here who don't know how to add this to Fusion, put the above in a .fu file (or download the attached file) and put it inside Fusion's Config:/ folder.

You do not have the required permissions to view the files attached to this post.

User avatar
intelligent machine
Fusionista
Posts: 427
Joined: Fri May 13, 2016 10:01 pm
Answers: 2
Location: Austin, Texas, USA
Been thanked: 32 times
Contact:

Re: Inject Script Action into Existing Menu: Possible?

#3

Post by intelligent machine » Sat May 18, 2019 8:27 pm

I was ALMOST there....tried maybe 10 different variations and was getting close:

After "File\\Save Version"

is what I needed.

Thanks!