Adding right click option to Slider-derived component


#1

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.

Thanks,

Sean Costello


#2

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.


#3

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
		
	}
	else
	{
		Slider::mouseDown(e);   // to the usual thing .... drag the slider
	}	
		
}

#4

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


#5

ah … good one. Thanks.