QCPort Extensions

cwright's picture

QCPort is the generic class used to pass data between patches in Quartz Composer. Creating specific extensions by subclassing QCPort is quite easy, and there are several methods you can override to accomplish some pretty neat tricks. This information is fairly incomplete at the moment, but it's enough to get started.

- (void)_setDirection:(int)fp8

This method is called once during initialization. The int passed to it is ether -1 or +1, for input and output respectively.


This method is called whenever the patcher interface needs to render the tooltip. This happens when the user hovers over the input or output port. The NSString returned by this method is used to fill in the data after the first two lines. Caution: Huge output will crash Quartz Composer :)

- (BOOL)canConnectToPort:(QCPort)fp8

This method is called when the user tries to connect an output to your input. The fp8 object is the port that wants to connect. You can query it to see what kind of data it exports, and then return TRUE or YES if you can accept that data, or FALSE or NO if you don't.

- (void)willChangeValue and - (void)didChangeValue

These two functions are pretty handy. The first one is called just before the input value is changed for your port. The second one is called just after it is changed. Using these allows you to handle value changes atomically.

- (BOOL)setState:(NSCFDictionary)fp8

setState is called at startup to fill in the initial values for your port. It provides you with a dictionary has the key "value" set to the value for your port. It is unclear what the return value signifies.

- (unsigned int)_timestamp

This methods returns a counter. However, it isn't a chronological counter, it's more like a revision counter. Each time the value of the port gets modified, this value increments. It starts at 0.

Ok, well that's about all the useful stuff I've gleaned thus far. If you find anything new or clarify, please post it here :)