In the day 1 video: Introducing the event object, near the
end (around 9.30) I read that the differences between target vs
currentTarget. One point says that the target always refers to the
So I'm thinking that if I set the event listener to the
button, the target will always be button. And if I set the event
listener to the panel (as in the video, around 10.28), I would have
thought that the target would then be the panel, but the video says
its still the button. That's the part I don't understand.
target is the event dispatcher. currentTarget is the level at
which the listeners were executed. Take a button. When you click on
it, the click might be on the UITextField (label of the button).
The event bubbles up to the Button (of which UITextField is a
child) and any click listeners attached to the button executes with
target as UITextField and currentTarget as the button.
Now consider the Panel case. When you have a click listener
on the panel and you click on the button, button got the click, the
event bubbles up to the parent. target will be the dispatcher
(button) and currentTarget will be where the listener is at