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
royjaydAsked:
Who is Participating?
 
dgofmanCommented:
forgot to delete listener


private function closePopup(event:FlexMouseEvent):void {
      event.currentTarget.removeEventListener(FlexMouseEvent.MOUSE_DOWN_OUTSIDE, closePopup);
      PopUpManager.removePopUp(dataGridPopup);    
}
0
 
dgofmanCommented:
add listener for your DataGrid instance

dataGridPopup.addEventListener(FlexMouseEvent.MOUSE_DOWN_OUTSIDE, closePopup);

private function closePopup(event:FlexMouseEvent):void {
      PopUpManager.removePopUp(dataGridPopup);    
}
0
 
royjaydAuthor Commented:
Is it must to impliment the removeEventListener() everytime when we do addEventListener ?

thanks
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
dgofmanCommented:
0
 
royjaydAuthor Commented:
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?
}
}
0
 
dgofmanCommented:
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  
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.