Just a question here. Do you really want to store multiple times a variable and automte updates on change? updating could lead to an endless cyclic feedback… isn’t possible in your application to have one single storage and get a pointer to it in as many objects as you want?
this could work if we allowed listeners that got a parameter by value but we don’t have support for that syntax yet. I’ve thought about this some times but never get to really add it. Probably for next version.
@Jordi
I would like to make links between objects at runtime. Something like the AE pick whip tool.
This way one objects parameter could control parameters of another object. Think of „Animated x-value of A changes transparency of B“.
@arturo
I am not very familiar with Lambda functions so please excuse if I don’t understand above statement ceompletely.
I get two errors
Lambda issue
ofApp.cpp:19:58: 'this' cannot be implicitly captured in this context
Semantic issue
ofParameter.h:434:7: Candidate function template not viable: requires at least 2 arguments, but 1 was provided
I guess the latter refers to the definition of ofParameter::addListener which excpects not only a callback function but also a class it should invoke it on.
The first I don’t quite understand. maybe it complains because the Lambda function doesn’t have test3 in it’s scope?!
That solves the missing reference to test3, thanks
But still missing the listener class
ofApp.cpp:20:24: No matching member function for call to 'addListener'
ofParameter.h:434:7: Candidate function template not viable: requires at least 2 arguments, but 1 was provided
oh yeah sorry i thought you were using events rather than parameters. with ofParameter if you want to use lambda functions you need to use newListener instead of addListener like:
where listener removes the listener whenever it’s deleted so you need to keep it around until you want that listener to keep working. for example by keeping it as an instance variable next to test1
Error:(153, 18) no matching member function for call to ‘addListener’
This other way (same than gui examples) is working but I am not sure can be problematic in some way. (Maybe i’ll need a bool to disable the listener when color_randomized -> color_picked, and use another listener.)
Ideally, I would like to add hue/sat/brgt sliders to my gui, to modify/receive the color(s) too, so I wouldn’t like to fall into callbacks ‘overflow’/loopback…
The problem is that you use .addListener method, and you should be using .newListener method, also you have to save the listener into a variable, see last post of Arturo in this thread, or this blog post about new event system in OF0.10: https://blog.openframeworks.cc/post/173223240829/events