Quantcast
Channel: bugs, errors - openFrameworks
Viewing all articles
Browse latest Browse all 636

ofParameter add listener not working

$
0
0

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.

Screenshot 2023-04-14 at 13.00.43

Screenshot 2023-04-14 at 13.10.38

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

Read full topic


Viewing all articles
Browse latest Browse all 636

Trending Articles