[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 197
  • Last Modified:

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
0
royjayd
Asked:
royjayd
  • 4
  • 2
1 Solution
 
dgofmanCommented:
add listener for your DataGrid instance

dataGridPopup.addEventListener(FlexMouseEvent.MOUSE_DOWN_OUTSIDE, closePopup);

private function closePopup(event:FlexMouseEvent):void {
      PopUpManager.removePopUp(dataGridPopup);    
}
0
 
dgofmanCommented:
forgot to delete listener


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

thanks
0
[Video] Oticon Case Study

Open office environments can create the dynamics for innovation, but they also bring some challenges. With over 1,000 employees in an open office, Oticon needed a solution that would preserve the environment while mitigating disruptive background noises.

Watch how they did it.

 
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

Featured Post

Big Data Means Big Business

In data-dependent industries like IT, finance, and healthcare, there’s a growing demand for qualified analysts to fill leadership roles. WGU’s MS in Data Analytics has IT certifications from Oracle and SAS built into its curriculum at a flat fee that could save you money.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now