Adding right click option to Slider-derived component

Hi all:

I’ve had a few “special order” requests concerning disabling sliders in my plugins. It would be nice to add a right click option to my slider class (which inherits from the Juce Slider class) to allow people to disable the slider. Is there an easy way of doing this? Searching for how to add right click options to Juce components didn’t work for me, but maybe there is some obvious thread I have missed.


Sean Costello

It doesn’t have any mechanism for adding to the built-in menu, but you could always just grab the mouse-click yourself and override it if you need some custom behaviour like that.

easy, but have it handy for reference:

void mySlider::mouseDown(const MouseEvent &e) {
	ModifierKeys modifiers = ModifierKeys::getCurrentModifiersRealtime();
	// check the mod keys ..
	if (modifiers.isRightButtonDown() || modifiers.isCtrlDown())

		 // do some stuff .. like display a menu
		Slider::mouseDown(e);   // to the usual thing .... drag the slider
1 Like

There’s actually a ModifierKeys::isPopupMenu() method that you should probably be using instead of explicitly looking for a right-button event.

ah … good one. Thanks.