Book a Demo

Author Topic: Menu Icon and Menu Item Type  (Read 6421 times)

hln

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Menu Icon and Menu Item Type
« on: October 01, 2013, 07:45:03 pm »
Hi,

I am develop Sparx Add-in and I have some questions:
  • Can I set icon to my menu items?
  • Can I select a type for my menu item? For instance: I want to some my menu items are "Radio Button" or "Checkbox" type.

Thanks

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Menu Icon and Menu Item Type
« Reply #1 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
Models are great!
Correct models are even greater!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Menu Icon and Menu Item Type
« Reply #2 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
« Last Edit: October 01, 2013, 08:34:52 pm by Geert.Bellekens »

hln

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
    • View Profile
Re: Menu Icon and Menu Item Type
« Reply #3 on: October 16, 2013, 06:15:40 pm »
I have another question: how to add horizontal line in menu.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Menu Icon and Menu Item Type
« Reply #4 on: October 16, 2013, 09:29:33 pm »
IIRC you simply supply a hyphen ('-').

q.

Pavel Bunygin

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Menu Icon and Menu Item Type
« Reply #5 on: November 08, 2013, 07:29:54 pm »
Hi!
Is there a way to add a shortcut key?

philchudley

  • EA User
  • **
  • Posts: 750
  • Karma: +22/-0
  • EA Consultant / Trainer - Sparx Europe
    • View Profile
Re: Menu Icon and Menu Item Type
« Reply #6 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
Models are great!
Correct models are even greater!

Pavel Bunygin

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Menu Icon and Menu Item Type
« Reply #7 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"
« Last Edit: November 08, 2013, 08:56:42 pm by PavelBunygin »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Menu Icon and Menu Item Type
« Reply #8 on: November 08, 2013, 10:34:28 pm »
AFAIR: Not possible. It has been asked here several times.

q.