Detecting Modifier Key when touching Slider/RotaryKnob

Yes, you have to explicitly pass data down every level.

struct Something
{
    SomeData& reference;

    SomeClass someClass; // this object knows nothing about "reference"
};

I would suggest brushing up on C++ basics before continuing with your complex project.

I figured about passing data down. And I hear you about my lack of C++, and I did actually take several days last week to do some brushing.

Anyways it is specifically the MySlider class, which is used to declare knobs inside my many modules, that need to invoke the same “lfoTargetComponent”, not the actually modules and that is what confuses the hell out of me.

Just a thought to make it easier for me, since the MySlider class is so small, perhaps I could put it into each component that uses it, then even I could figure out to pass each the “lfoTargetComponent” reference. However still it is 45 times repeating code :frowning:

struct MySlider
{
    MySlider (lfoTargetComponent&);
};

class SomeComponent
{
    SomeComponent (lfoTargetComponent& lfo)
      : slider (lfo)
    { }

    MySlider slider;
};

Ok thank you very much for that. I will try to use that example to get it to work!

I’m now trying to expand MySlider to also include the functionality to open a component containing a text or label field, to allow manual precise entry of any parameter value by pressing my rotary slider with the Ctrl key.

#pragma once

#include <JuceHeader.h>

#include "SetModifierTarget.h"
#include "ParameterEntryComponent.h"

//==================================================================
class MySlider : public juce::Slider {
public:
    MySlider () = default;

    MySlider (const juce::String& componentName) : 
juce::Slider (componentName) {}

    MySlider (juce::Slider::SliderStyle style, 
juce::Slider::TextEntryBoxPosition textBoxPosition) : 
juce::Slider (style, textBoxPosition) {}

    void mouseDown (const juce::MouseEvent& event) override
    {
        if (juce::ModifierKeys::currentModifiers.isRightButtonDown ())
        {
            int module;

            // Module knob
            if (Slider::getProperties ().contains ("Section"))
                module = int (Slider::getProperties ()["Module"]);

            // Detail knob
            else
                module = -1;
            
            modifierTargetPtr->setModifierTargetStatus 
              (Slider::getComponentID (), Slider::getTooltip (), module);
        }
        else if (juce::ModifierKeys::currentModifiers.isCtrlDown ())
        {
            entryTargetPtr->setEntryTargetStatus 
              (Slider::getComponentID (), Slider::getTooltip (),
                Slider::getValue ());
        }
        else
            juce::Slider::mouseDown (event);
    }

    void setEntryTargetComponentPtr (ParameterEntryComponent* ptr)
    {
        entryTargetPtr = ptr;
    }

    void setModifierTargetComponentPtr (SetModifierTarget* ptr)
    {
        modifierTargetPtr = ptr;
    }

private:
    ParameterEntryComponent* entryTargetPtr = NULL;
    SetModifierTarget* modifierTargetPtr = NULL;

    JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MySlider)
};

However I’m not sure how to pass the newly entered, altered value back to PluginEditor so it can trigger SliderValueChanged.

I’m naively thinking how to pass the below entire Slider object to the function entryTargetPtr->setEntryTargetStatus (Slider) in SetModifierTarget.cpp, instead of passing parts of the slider objects as below;

entryTargetPtr->setEntryTargetStatus (Slider::getComponentID (), 
Slider::getTooltip (), Slider::getValue ());