0
votes

In my app I currently have a popup menu implemented as a BorderContainer with a lot of buttons, textfields, date pickers, etc. PopUpManager handles its appearing and disappearing based on some UI events.

I'd like to be able to drag the container by clicking on any part of it minus all the components on it. In other words, when I click on buttons, text fields, etc. I'd like for them to respond as usual and for the container not be draggable.

I've tried this very simple implementation

_menu.addEventListener(MouseEvent.ROLL_OVER, toggleDragON);
_menu.addEventListener(MouseEvent.ROLL_OUT, toggleDragOFF);

private function mouseDown(event:MouseEvent):void 
{ 
    _menu.startDrag(); 
} 

private function mouseReleased(event:MouseEvent):void 
{ 
    _menu.stopDrag(); 
}

but this definitely doesn't do the trick, i.e. all components lead to dragging. I've tried to make sure that mouseEnabled and mouseChildren are true for all the components but this doesn't seem to make any difference.

I then came across this thread which makes a lot of sense, but I have a hard time believing that the best way for one to handle this is to handle all click events for each of the components on the popup. Is there an obviously simple way to do this that I'm missing?

thank you!

f

1
You might want to restrict the dragging to a title bar or something like that; You can drag a window only by its title bar - not by any other free space in the window. - Amarghosh
that makes sense - in fact I've done similar things with TitleWindow components and things were a lot more straightforward. This time the design calls for no title bar, so I don't think it'll work. - fred august
Can you post a stripped-down MXML showing your problem on pastie or similar? I'd like to have a go at figuring this one out :) - Sophistifunk

1 Answers

2
votes

How about checking the target property of the event to check if it equals your menu?

if (event.target == _menu) {
    _menu.startDrag();
}