I have the following code:
recognizer = new GestureRecognizer();
recognizer.Tapped += (args) =>
{
// Send an OnSelect message to the focused object and its ancestors.
if (FocusedObject != null)
{
FocusedObject.SendMessageUpwards("OnSelect",
SendMessageOptions.DontRequireReceiver);
}
};
I am working in a project for Unity and I am not that experienced with the syntax of this operation:
recognizer.Tapped += (args) =>
{
// Send an OnSelect message to the focused object and its ancestors.
if (FocusedObject != null)
{
FocusedObject.SendMessageUpwards("OnSelect",
SendMessageOptions.DontRequireReceiver);
}
I understand that Tapped
is the event listener for taps. However, I don't understand the following things:
1) Why are they using a +=
operator to add a lambda function. How can you add a lambda function like that? I've always used +=
on primitive types.
2) Where does "args" come from?
3) When does that lambda function run?