Difference between event.tar get and event. currenttarget properties in an event object.

Source: Internet
Author: User

Http://mysticnomad.wordpress.com/2008/03/21/difference-between-eventtarget-and-eventcurrenttarget-properties-in-an-event-object/

In Flex, an event object is created whenever an event is dispatched. The event object has two important properties-event.tar get and event. currenttarget.The event.tar get property references the event dispatcher while event. currenttarget property refers to the node which is currently being checked for event listeners.While event.tar get property stays the same throughout the event flow (Capturing, targeting and bubbling phases), The event. currenttarget property changes on each node.

For example, if an event is fired from a textinput component placed inside a panel, event.tar get in this case will be textinput throughout the event flow while event. currenttarget will vary from application to panel to textinput as the event object goes up or down the flow chain.

An important point to note over here is that when an event is fired from a component, Event.tar get property does not necessarily reference the component which dispatched the event. It may refer to a subcomponent which is part of that component. This means that if you click on a button's label, the event object's event.tar get property won't be button (as you might have got Ed) but will be a subcomponent ( Within the button class )-Uitextfield ( Renders label in a button ). This is a very important point while handling events. in this case, if the button component was listening for the click event, the event handler will be called if you are using event. currenttarget property since (sooner or later) event. currenttarget will refer to the button component as the mouse event bubbles through the chain. but, if you were using event.tar get property, the event handler will never get called as a subcomponent ( Uitextfield ) Fired the event and is referred to in event.tar get property. Hence, You shoshould always use event. currenttarget property instead of event.tar get.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.