Value callbacks for repeated values

When you call juce::Value::setValue(), you only get a listener callback if the value is different than the last one–repeated values are filtered out. That makes sense in most situations, but is there any way of overriding it? With ValueTree you have sendPropertyChangeMessage and setPropertyExcludingListener, both of which would be helpful for this, but I don’t see any equivalent methods in Value.

The reason I’m asking is that I have a series of PropertyComponents that work using Value callbacks, and I want the ButtonPropertyComponent to work off of the same callbacks. I could just send an incrementing number so that the callbacks get flushed, but this feels like a bit of a hack, and I’d rather be sending void or undefined vars. Is there any way of doing this?

I don’t believe there is any way to do this with raw a ValueTree. I do most of my ValueTree related operations through a wrapper class, where I have a settable state which manages that.

        if (! filterNonChange && previousValue == value)
            data.sendPropertyChangeMessage (property);

But I think you are directly asking how to pass a button click, which I do with a toggle operation in the same class

    void toggleValue (const juce::Identifier property, bool includeSelfCallback)
    {
        setValue (! getValue<bool> (property), property, includeSelfCallback);
    }

I ran into this issue a couple times and had to hack together something very similar.
In the end it always turned out, that the ValueTree was really not the appropriate back bone or I didn’t use the ValueTree properly at a different piece of the code.

With buttons that are not toggle-able, I almost always end up with an ApplicationCommand button.

Thanks for your input. Please note though that I’m talking about juce::Value here, not ValueTree. Most of your input is the same though, and I agree that this is not the proper channel for buttons. The issue in my case is that I have a whole series of PropertyComponents that all work with juce::Value, and it would be a real pain to have to set up another listener channel just for this one case.

This is what I’m doing for now to solve the problem:


class ButtonClickID : public juce::ReferenceCountedObject
{
public:
    ButtonClickID() = default;

    static juce::var singletonA, singletonB;
};

juce::var ButtonClickID::singletonA = new ButtonClickID();
juce::var ButtonClickID::singletonB = new ButtonClickID();

void ButtonPropComponent::buttonClicked()
{   
    if (value == ButtonClickID::singletonA)
        value = ButtonClickID::singletonB;

    else value = ButtonClickID::singletonA;
}

Later on, the two instances of ButtonClickID are filtered out and replaced with undefined. I don’t like this at all, but it works.

Would it be a fair feature request to ask for a sendPropertyChangeMessage() method on juce::Value, like on ValueTree? It can’t imagine that it would be complicated, and it would make this case much easier to deal with.