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

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

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

dgopois
12-Amethyst

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

1 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!

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.

Top Tags