Listen only to manual slider changes


#1

I’m using the JUCE attachments for the sliders in the plugin. I want to display the value when a user changes a slider.
When i attach a listener to the slider i get also notifications when the plugin is automated through the attachment and not only when the user changes it manually with the mouse.
Overwriting mouseDrag of the slider class does not work (nothing happens, i’m not sure why), while mouseEnter works fine. Any ideas?


#2

Are you subclassing Slider? If you are and you’re overriding the mouseDrag() method make sure to call the superclass mouseDrag() method from within your subclass otherwise lots of things won’t work.

It’d be helpful if you could post some of the code as it could be any number of things.


#3

Thanks for getting back. Thats what i expected too, but it seems that the mouseDrag method never been called while mouse enter works (i’m having the whole code in a header file without cpp):

void mouseEnter(const MouseEvent& event) override
{
    if (this->talShowOnDisplayCallback != nullptr)
    {
        this->talShowOnDisplayCallback->showSliderValue(this);
    }
}

void mouseDrag (const MouseEvent& event) override
{
    Slider::mouseDrag(event);
    
    if (this->talShowOnDisplayCallback != nullptr)
    {
        this->talShowOnDisplayCallback->showSliderValue(this);
    }
}

I don’t understand that. Does the attachment steal the drag method somehow?


#4

No, I don’t think that’s possible. Can you post a minimal code example which demonstrates the problem?


#5

Thanks for your answer. Sorry, i forgot that i have two different classes that overwrite Slider. The world is now ok again. MouseDrag seems the way to go when you only want to get notifications for manual user actions. I think i also have to overwrite the mouse wheel actions to make it complete.