startAction(_:)
Prepares the host to access parameters.
Declaration
func startAction(_ sender: Any!)Parameters
- sender:
The view class that implements this protocol. Typically passed as self.
Mentioned in
Discussion
OSC plug-ins (implementing FxOnScreenControl_v4) should not use startAction(_:) and endAction(_:), as the host is already aware that parameters are likely to change.
Starting with FxPlug 4, the startAction(_:) function is more heavyweight than in the past. Calling startAction(_:) will cause the host application to gather up the value of all parameters in the plug-in and send them to the XPC service. Any calls to the FxUndoAPI, FxParameterSettingAPI_v6, FxParameterRetrievalAPI_v7, or FxKeyframeAPI_v3 will be queued up and sent to the host in bulk once you call endAction(_:). Therefore you should avoid making calls like this:
This code will not work properly. The calls to startAction(_:) and endAction(_:) in the first block will cause the host app to start an undo group without closing it in the same run loop. The calls to set the parameter will not be enclosed in an undo group and will be executed in a different run loop occurrence than the call to startUndoGroup(_:) in the host application. The call to end the undo group will occur in a third run loop in the host app and will be unbalanced.
Instead you should call startAction(_:) before all actions you want to perform, and call endAction(_:) after all actions have been completed, like this:
This will work as intended and start a single undo group that contains the parameter change.