How to remove popup when right-clicking on buttons

I’d like to assign two different functions to a button if is left or right clicked.
I found this thread (link) and tried to modify it.
It works, but on right click the usual rack parameter window opens, and I don’t want this.
How could I do it?

struct ParameterBut : VCVBezel {
	void onButton(const event::Button &e) override {
		Test2functBut *module = dynamic_cast<Test2functBut*>(this->module);
		DEBUG("button clicked");
		if (module) {
			DEBUG("module is defined");
			if(e.button == GLFW_MOUSE_BUTTON_LEFT && e.action == GLFW_PRESS) {
				DEBUG("LEFT CLICK");
			}

			if (e.button == GLFW_MOUSE_BUTTON_RIGHT && e.action == GLFW_PRESS) {
				DEBUG("RIGHT CLICK");
			}

		}

		VCVBezel::onButton(e);
	}
};

I’m not convinced it is a good idea, but if you really want to disable the default popup options, then simply remove the last line:

		VCVBezel::onButton(e);

The concept is the same for any overridden method. If you want to add additional functionality to what is already there, then make sure your method calls the base method. You have control over when the base method is called. Possibly at the top before your code, at the bottom after your code, or maybe even in the middle.

If you want to completely replace the functionality with your own implementation, then don’t call the base method.

What kind of nonsense did I write ! :crazy_face: :flushed:

Perhaps the bottle of wine I consumed last night hadn’t yet left my system. :roll_eyes:

2 Likes

I tried with the result that parameter window is no more displayed, but now, by right-clicking on button, the standard module default window opens, and I wouldn’t even want this.

Ugh, sorry. I totally did not give your problem enough thought before I spouted off.

I don’t know enough about all the myriad mouse action event handlers to answer your question.

But to block default behavior, I suspect you may have to delve into controlling whether your event handler consumes the event or not. Again, I don’t know the particulars here. Or I might be totally off base again!

Thanks, I appreciate your try

Unless you have an extremely compelling reason to do this that cannot be realised in any other way, I’d suggest from a user experience point of view this would be a bad idea.

I know well that in the real world a button can only have one way of being pressed, but here we have a mouse with two (…and more) commands.
I would simply like to have a button that has the ‘mute’ function with the left button, and the ‘solo’ function with the right, without having to double the number of buttons.

I imagine the only way is to make a new button class, just like Bogaudio

I think you mean in the physical eurorack world. Software is, actually, in the real world, and one can do almost anything while still being in the real world.

Exactly

Without looking at the code too closely, consume the event and don’t call he parent class onButton method if you are in your cases wheee you handle it is what I’d try first.

3 Likes

please don’t.

Ideally, IMHO, everything should be compatible with MIDI-MAP (and Stoermelders MIDI CAT).

2 Likes

I agree that should be compatible with midi mapping, at least with one of the two button functions. I see that Bogaudio mixers’ mute/solo buttons work by feeding different voltages to them. I’m working to code the button class properly.

A completely new button class worked fine, just like Bogaudio mixer buttons, and at least the main function of the buttons can be easily midi mapped. Obviously the unmap menu item on the button context-menu is no longer available. Thanks everyone for the answers.

1 Like