Dropdown menus

Post Reply
ymerejsasnak
Posts: 69
Joined: Thu Jun 04, 2020 2:08 am

Dropdown menus

Post by ymerejsasnak »

Hello...

Is there a way to trigger default right-click menu behavior after you've taken control of a component with "Wants Mouse Notifications"?

Basically what I'm trying to do is add a left-click menu on part of my module without blocking the default right-click menu. Is this possible in any way?

JK
User avatar
honki-bobo
Posts: 305
Joined: Sat Nov 09, 2019 1:18 pm

Re: Dropdown menus

Post by honki-bobo »

Hey Jeremy,

I guess what you are looking for is the " int ShowDropDownMenu(String[] options, int currentlySelectedIndex, VoltageComponent showMenuUnderThisObject)" method of the VoltageModule object.

Once you get the hang of it, it is actually quite convenient.

You'll need a String[] that holds the menu items, e.g.

Code: Select all

private String[] waveforms = {"sin", "tri", "sqr", "saw", "rmp"};
, an int to hold the selected index, e.g.

Code: Select all

private int menuSelection = 0;
and a VoltageComponent you want to attach the menu to, e.g.

Code: Select all

private VoltageButton menuButton;
In the "Notify" method add the following to the Button_Changed case:

Code: Select all

if (component == menuButton) {
    menuSelection = this.ShowDropDownMenu(waveforms, menuSelection, menuButton);
    if (menuSelection == 0) {
        //do something
    } else {
      // do something else
    } // ... and so on
}
Hope this helps.

Have a merry Christmas and happy holidays!
Image
Monkey Business Audio
Modules - Music - Twitter - YouTube
ColinP
Posts: 940
Joined: Mon Aug 03, 2020 7:46 pm

Re: Dropdown menus

Post by ColinP »

I think what JK is after is a means of calling up the default VM right-click menu rather than just a custom menu.

I have a similar problem with trying to create programmatically operable toggle buttons from normal buttons. My code works but it disables VM's right-click menu for some reason.

How some events are dispatched in VM is a bit of a mystery but it would be handy to be able to call up the right-click menu from our own code so that we can replicate "normal" behaviour.
Post Reply

Return to “Module Designer”