add newListener() method to ofParameter#4784
Merged
arturoc merged 1 commit intoopenframeworks:masterfrom Feb 5, 2016
Merged
Conversation
if you want to use an ofEventListener to respond to an ofEvent, you have to create one using a templated factory method which is part of ofEvent<T>. Since ofParameter shields users from accessing its data directly by holding it inside a private data `obj`, there is no way to call the `newListener` factory method on a parameter changed event which you want to observe. This PR proposes to add a `newListener` method to `ofParameter`, which will, based on dark templating magick, forward any of its parameters to the `ofEvent` object held by the private `ofParameter::obj`. I wish there was a simpler way, but this seems to me the best way to observe an ofParameter and responding to any changes using a lambda. Minimal testcase: <https://gist.github.com/tgfrerer/f9fc6e3b2ebe88633ab5>
arturoc
added a commit
that referenced
this pull request
Feb 5, 2016
add newListener() method to ofParameter
Member
|
thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If you want to use an
ofEventListenerto respond to anofEvent, you best create one using a templated factory method which is part ofofEvent<T>.Since ofParameter shields users from accessing its data directly by holding it inside a private data
obj, there is no way to call thenewListenerfactory method on a parameter changed event (changedE) which you want to observe.This PR proposes to add a
newListenermethod toofParameter, which will, based on dark templating magick, forward any of its parameters to theofEventobject held by the privateofParameter::obj.I wish there was a simpler way, but this seems to me the best way to observe an ofParameter and responding to any changes using a lambda.
Minimal testcase:
https://gist.github.com/tgfrerer/f9fc6e3b2ebe88633ab5