Hi I tried to add a listener to an ofParameter, however I get build errors on xcode. Wich is wreird as a parameter should be able to have a listener.


Class ServerConfig
public:
ofParameter<string> url;
ofParameter<int> ntpPort;
Class ServerConfigPanel
/*
* add listener
*/
template <class ListenerClass, typename ListenerMethod>
void addListenerServerValues(ListenerClass *listener, ListenerMethod method)
{
ntpField.addListener(listener, method); // this one will forward the listener to the appropiate parameter (stored in config->server->ntpPort)
config->server->ntpPort.addListener(listener, method); // this is a direct call to the parameter
// both calls individually will give the compile error shown in the image
}
ServerConfigController constructor
views->serverConfigPanel->addListenerServerValues(this, &ServerConfigController::fieldchangeServerDestination);
openframeworks V0.11.2 (main release)
addons
- csv
- gui
- network
- xmlSettings
Adding a listener to a ofxButton in the same fashion works like a charm, so to my surprise this did not work. Am i doing it wrong because we are using an ofParameter, am I missing something? or is something wrong in ofParameter?
Ultimate goal.
When something in the server configuration changes i need to call our ntp syncing function to update our ntp timestamp and reset the internal openframeworks clock
After 15 minutes: I created a workaround to add an extra button to trigger the sync after you changes the values, but still I do not understand why the listener on the parameter is not working.
5 posts - 3 participants