Script connection object trigger method#1198
Conversation
Previously, engine.trigger(group, key) had to be called by scripts, which would trigger all callbacks connected to that ConfigKey. This new method allows more fine-grained control by scripts.
|
LGTM. Though I cannot test this. I sure you did ;-) |
|
Wait, can you please add a test for this new function? |
|
Yeah, I'll open a new PR with a test. I consider this a quick hack for 2.1. For 2.2 I'd like to rethink this functionality and provide a nicer, more JavaScriptish syntax (something like |
|
Still, anything we're exposing to the users will a) need to be supported and b) unit tested to ensure it works as expected in the future. (If you want to do quick hacks, do them in script, not user-facing APIs.) |
|
I think this still triggers all the callbacks since it does the same thing ControllerEngine::trigger does (causing the ControlObjectScript to emit a valueChanged signal). To just trigger the connection itself I think you would need to call the logic in the loop in ControlObjectScript::slotValueChanged for just the ControllerEngineConnection in question. |
No, it does not, because it is up to the script to keep track of the connection objects and specifically trigger the appropriate connections. engine.connectControl() returning a connection object has never been documented. I discovered it accidentally by reading the C++ source (refer to #656). For the most part, this should be abstracted away by Components. Script authors should only have to use that functionality directly when implementing a custom |
Hm, are you sure? ControllerEngine::triggerControl looks up the ControlObjectScript using the string group/item and tells it to emitValueChanged. This should be equivalent to ControllerEngine::trigger(connection.key.group, connection.key.item).
👍 this isn't a big deal since it was never documented in the first place. It's still nice to have tests though :). |
Was this meant for #1196? |
Oh, you're right. I'll try modifying ControllerEngine::triggerControl to specifically call the connection's callback instead of calling the COScript's emitValueChanged method. |
Previously, engine.trigger(group, key) had to be called by scripts, which would trigger all callbacks connected to that ConfigKey. This new method allows more fine-grained control by scripts.