Products
Technologies

Developer resources

ToggleButton to display PopUpAnchor and use of "mouseDownOutside" event

Not yet rated.

Problem

When using mouseDownOutside with PopUpAnchor, clicking the toggle button was not closing the PopUpAnchor Popup.

Solution

Use the event.relatedObject of the mouseDownOutside event and determine if the ToggleButton is the relatedObject.

Detailed explanation

Using a toggle button to open and close a PopUpAnchor I found that the user wanted a mouseDown external to the popup to trigger the close of the popup. I found the "mouseDownOutside" event that can be used in a child of a PopUpAnchor to trigger an event that I can attach the close to. In doing this I found that the clicking the toggleButton would dispatch 2 events. Rather than trying to change my code to use the events and try and stop one of the events from occuring. The following is a solution that I thought was simple, and that I would share on Cookbooks.

<s:ToggleButton
        x="8" 
        y="7"
       
skinClass="com.tass.intranet.binary.ui.skins.SearchOptionsToggleSkin"
        id="my_toggle"
        selected="{ displayMyPanel }"
        click="displayMyPanel = true;"
/>

<s:PopUpAnchor top="115" right="302" displayPopUp="{
displayMyPanel }">
                
        <s:Panel 
                id="my_panel"
                mouseDownOutside="if ( event.relatedObject !=
my_toggle ) { displayMyPanel = false; }"
        />
        
</s:PopUpAnchor>


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes