I am trying to receive notifications from objects in a sketch. I can option click classes to see lists of functions and properties. Where do I find a list (besides the source) or documentation of the notifications that objects emit?
Specifically I would like to catch the TOUCHDOWN event from a button using the [self listenFor...] syntax from my C4Workspace.m
In general, native objects don't push notifications. For a list of C4 objects that emit them, have a look at section 2.1 and 2.2 of the following document:
http://c4ios.com/workshops/vivo/interaction.php
Buttons and other UI elements act like objects from UIKit. This means that they don't create TOUCHDOWN
notifications when they are touched. They actually have a mechanism that lets them push "actions" or "messages" to other objects when various control events occur.
Instead of the following:
[self listenFor:@"TOUCHDOWN" fromObject:aButton andRunMethod:@"someMethod"];
You would do the following:
[button runMethod:@"aMethod" target:self forEvent:TOUCHDOWN];
Which allows you to bind the aMethod
for the target object (here it is self
) to be sent whenever the button receives a TOUCHDOWN
event.
For UI elements there are a lot of different control events:
TOUCHDOWN
TOUCHDOWNDRAGINSIDE
TOUCHDOWNDRAGOUTSIDE
TOUCHDOWNDRAGENTER
TOUCHDOWNDRAGEXIT
TOUCHUPINSIDE
TOUCHUPOUTSIDE
TOUCHCANCEL
VALUECHANGED
This is just a short list of the control events that you can use in combination with UI elements.