Keep context menu open on control-click

I’ve been told that some modules will keep the context menu (the right-click menu) open when users control-click on menu items.

In other words:

  • If a user clicks on a menu item, then the context menu closes (default)
  • If a user holds down the control key while clicking on a menu item, then the context menu does not close (my desired behavior)

Can someone guide me toward how that’s done?


Clocked does it, and it’s open source, so that may be a good place to look.

Having said that, the Rack v2 changelog has this: “If Ctrl+clicking on any menu item, the menu stays open (except for some menu items like “Delete Module”).”

1 Like

Yep - we all get the feature for free. I have been using menu Ctrl-click for a while now. For example, it is a nice way to quickly cycle through various context menu options for testing. Or for demo purposes, to cycle through context menu over-sampling options to show the effect it has - It is nice for the viewer to see the selection after it has been made.


I’m away from my computer, but I recall seeing a menu item flag for “dismiss on click”.

Is that a rack global setting or something a particular module did? I don’t see an option like that in rack or in the small number of modules I just looked at.

My memory summarized too much :-/. The menu closing behavior on click (and how to modify it) is documented here:


struct MenuItem : MenuEntry {
	/** Override to handle behavior when user clicks the menu item.
	Event is consumed by default. Unconsume to prevent the menu from being closed.
	If Ctrl (Cmd on Mac) is held, the event is *not* pre-consumed, so if your menu must be closed, always consume the event.
	void onAction(const ActionEvent& e) override;

i just wanted to add my 2 cents on this, as it was recently brought to my attention by @Omri_Cohen that one of my modules wasn’t properly updating the menu when ctrl+clicking.

turns out i was previously using something like this:

menu->addChild(createMenuItem("uniform", CHECKMARK(module->randomMode == Noize::UNIFORM),
			[=]() { module->randomMode = Noize::UNIFORM; }));

which did allow ctrl+clicking, but as i said wouldn’t update the menu display to show that the item was toggled until closing and reopening the menu.

changing it to createCheckMenuItem() solved this.

menu->addChild(createCheckMenuItem("uniform", "",
			[=]() { return module->randomMode == Noize::UNIFORM; },
			[=]() { module->randomMode = Noize::UNIFORM; }));

(EDIT: also, in case anyone currently uses or eventually uses @Patheros’s “cvRange” micro-lib (GitHub - patheros/VCV-MicroLibs: A collection of one-file-libraries for VCV Rack Development), i submitted a PR to his repo to make sure the menus added by the library also use createCheckMenuItem() calls, and the PR was merged)

(EDIT #2: changed createMenuItem() call to how i was actually using it before the fix)


Good find!

I know I ran into this behavior before. I just can’t remember whether it was with one of my modules or not. I need to test my modules, and now I know how to fix the problem if I find it. Thanks!

1 Like

@alefnull Thanks a ton! :star2: :trophy:

My code was pretty outdated and didn’t use the shortcuts available these days. I updated all of my menu code to the “new” (more streamlined) code and it works great. Your replies have been super helpful, as always!


hey not a problem, glad it was useful info to people :smiley:

since i still consider myself very much an amateur programmer, i’m very glad i’m at least occasionally able to offer some semblance of useful info lol