Link to home
Start Free TrialLog in
Avatar of Jay Roy
Jay RoyFlag for United States of America

asked on

closing PopUp when clicked outside of it

hi guys

I have a scenario where i am using

PopUpManager.addPopUp(dataGrid, this, false);

If user clicks on the screen anywhere outside of the popup, the popup should close.

any idea if that is possible?

thanks
Avatar of dgofman
dgofman
Flag of United States of America image

add listener for your DataGrid instance

dataGridPopup.addEventListener(FlexMouseEvent.MOUSE_DOWN_OUTSIDE, closePopup);

private function closePopup(event:FlexMouseEvent):void {
      PopUpManager.removePopUp(dataGridPopup);    
}
ASKER CERTIFIED SOLUTION
Avatar of dgofman
dgofman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jay Roy

ASKER

Is it must to impliment the removeEventListener() everytime when we do addEventListener ?

thanks
Avatar of Jay Roy

ASKER

just curious
If i have VBox insteaad of Popup , should i say

public class DetailsGrid extends VBox
public function DetailsGrid (){
this.addEventListener(FlexMouseEvent.MOUSE_DOWN_OUTSIDE, closeDetailGridopup);
}
private function closeDetailGridopup(event:FlexMouseEvent):void {
      event.currentTarget.removeEventListener(FlexMouseEvent.MOUSE_DOWN_OUTSIDE, closeDetailGridopup);
      removeChild(this);  -- if i want to remove the Vbox , will this work?
}
}
You cannot remove the reference to your own object.
1) "this" is not children of "this" it's not make sense "this.removeChild(this);" - your father has child himself
2) When you are destroying the popup all references will be gone you don't need to remove any children