can we get the object from which focus has been stolen on click on other object ? ActionScript
for example i have object one a Textinput haveing id="
id_txtBox
", and a panel having a lot of children(TextInputs, Trees, Buttons etc.).. if user is editing text in one of panel's child and then clik on "id_txtBox". can we get to know
the id/object user were editing before the click on 开发者_StackOverflow"id_txtBox
". i mean from which object the "id_txtBox" has stolen focus..?
Add an event listener to each child that will update a currentChild property by getting the name of the clicked element.
var previousChild:DisplayObject; var currentChild:DisplayObject; panelChild.addEventListener(MouseEvent.CLICK , clickHandler ); private function clickHandler(event:MouseEvent):void { //to avoid an error on the first click if(currentChild != null ) previousChild = currentChild; // do whatever you need to do here, after it's complete, update the currentChild value; // this way the previousChild value indicates the object that was clicked before currentChild = this.getChildByName(event.currentTarget.name ); }
You can maintain history of objects in focus internally. So whenever an object acquires focus add it to the history. So if you want to query from which object, current focussed object has stolen focus you need to check the previous object in the history. You can setup your history to store as many object as you want according to your needs and keep removing the oldest object history exceeds its size.
精彩评论