Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: hln on October 01, 2013, 07:45:03 pm

Title: Menu Icon and Menu Item Type
Post by: hln on October 01, 2013, 07:45:03 pm
Hi,

I am develop Sparx Add-in and I have some questions:

Thanks
Title: Re: Menu Icon and Menu Item Type
Post by: philchudley on October 01, 2013, 08:02:11 pm
With regards to check box style menus, you can use code similar to the following

public void EA_GetMenuState(EA.Repository repository,
                                    string menuLocation,
                                    string menuName,
                                    string itemName,
                                    ref bool isEnabled,
                                    ref bool isChecked)
        {

            switch (itemName)
            {
                case "&Enabled":
                    isEnabled = true;
                    isChecked = menuIsChecked;
                    break;
                case "&About":
                    isEnabled = true;
                    break;
             }
        }


Where menuIsChecked is a local variable of type bool

To toggle the menu (i.e. react to the user menu click) use something similar to the following

public void EA_MenuClick(EA.Repository repository,
                                    string menuLocation,
                                    string menuName,
                                    string itemName) {
            switch (itemName) {
                case "&Enabled" :
                    menuIsChecked = !menuIsChecked;
                    break;
                case "&About" :
                    aboutBox = new AboutBox();
                    aboutBox.ShowDialog();
                    aboutBox = null;
                    break;
            }


All the best

Phil
Title: Re: Menu Icon and Menu Item Type
Post by: Geert Bellekens on October 01, 2013, 08:34:39 pm
Just to be clear, you can only do the checkbox thing with menu's.
No icons or radio buttons or anything else fancy.

Geert
Title: Re: Menu Icon and Menu Item Type
Post by: hln on October 16, 2013, 06:15:40 pm
I have another question: how to add horizontal line in menu.
Title: Re: Menu Icon and Menu Item Type
Post by: qwerty on October 16, 2013, 09:29:33 pm
IIRC you simply supply a hyphen ('-').

q.
Title: Re: Menu Icon and Menu Item Type
Post by: Pavel Bunygin on November 08, 2013, 07:29:54 pm
Hi!
Is there a way to add a shortcut key?
Title: Re: Menu Icon and Menu Item Type
Post by: philchudley on November 08, 2013, 08:05:09 pm
Isn't that what the & in front of a letter in the menu item name supposed to do?

I believe it works with either the Ctrl or Alt key, haven't tried in my extensions though

Cheers

Phil
Title: Re: Menu Icon and Menu Item Type
Post by: Pavel Bunygin on November 08, 2013, 08:56:02 pm
It works when a menu is already open for navigation. But I want execute my function by pressing something like Ctr-Q without opening a menu and going through it.
It should look like this:
"My Function      Ctr+Q"
Title: Re: Menu Icon and Menu Item Type
Post by: qwerty on November 08, 2013, 10:34:28 pm
AFAIR: Not possible. It has been asked here several times.

q.