cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

With an ACL function, how to add a menu when Arbortex Editor starts

dgopois
13-Aquamarine

With an ACL function, how to add a menu when Arbortex Editor starts

Hello,

I tried to add a menu using an ACL function in a script file init.acl (C:\Program Files\PTC\Arbortext Editor\custom\init\init.acl) but the menu is not loaded.

I want the menu to load when Arbortext Editor is starting.

Script:

function load_menu() {}
function load_menu() {

mad -before ".File.Close" "Test" -cmd {};
}

load_menu()

Regards

Can you help me?

David

ACCEPTED SOLUTION

Accepted Solutions

Hi David,

Here is a simple example for adding a menu after the Help menu in Editor.

An important note is to put your load scripts into the /init folder within your custom folders. Any scripts in this folder load when Editor opens. You also need to use a menuloadhook to load the menu function.

function initMenus(){

menu_add -menu .Help "MyMenu";

menu_add .MyMenu. "MyCommand" -cmd {myFunction()}

}

add_hook("menuloadhook","initMenus");

Hope that helps!

View solution in original post

3 REPLIES 3

Hi David,

Here is a simple example for adding a menu after the Help menu in Editor.

An important note is to put your load scripts into the /init folder within your custom folders. Any scripts in this folder load when Editor opens. You also need to use a menuloadhook to load the menu function.

function initMenus(){

menu_add -menu .Help "MyMenu";

menu_add .MyMenu. "MyCommand" -cmd {myFunction()}

}

add_hook("menuloadhook","initMenus");

Hope that helps!

dgopois
13-Aquamarine
(To:JeffStevenson)

Hi Jeff,

Thank you for your help.

David

As a further explanation: the reason you can't just put your menu_add commands in init.acl is that init.acl executes before the window is created. Since the main window doesn't exist yet, there's nowhere to put the new menu item when init.acl runs.

Using the menuloadhook solves that problem by making sure the menu_add command(s) run when the menu controls are built. This has the added advantage of making sure your modifications run every time the menu is refreshed (e.g. when a new window is created), and not just when Arbortext Editor starts up the first time.

Announcements

Top Tags