Open GoogleCodeExporter opened 9 years ago
Yes, the issue is that the MOUSE_UP event can never reach the VisualGraph if the
mouse is lifted outside of the area. I am not sure how to handle this best. It
could
be up to the final application to dispatch the event onwards to the VisualGraph
object.
Any input welcome.
Original comment by spo...@gmail.com
on 18 May 2008 at 6:33
[deleted comment]
Here's how I fixed this issue.
Fixes:
- Stop dragging on MOUSE_UP over non-canvas display object. (described issue)
- Stop dragging on MOUSE_LEAVE.
1) FlexVisualGraph.mxml - add the following to the init() function:
private function init():void {
...
addEventListener(MouseEvent.MOUSE_UP, stageMouseUp);
systemManager.stage.addEventListener(Event.MOUSE_LEAVE, mouseLeave);
}
2) FlexVisualGraph.mxml - add the 2 following functions:
private function stageMouseUp(e:MouseEvent):void {
vgraph.dispatchEvent(new Event('stage_mouse_up'));
}
private function mouseLeave(e:Event):void {
vgraph.dispatchEvent(new Event('mouse_leave'));
}
3) VisualGraph.as - add the following to the constructor:
public function VisualGraph():void {
...
addEventListener('stage_mouse_up', possibleDragEnd);
addEventListener('mouse_leave', mouseLeave);
}
4) VisualGraph.as - add the following:
private function possibleDragEnd(e:Event):void {
trace("possibleDragEnd");
if(_backgroundDragInProgress) {
dragEnd(null);
}
}
private function mouseLeave(e:Event):void {
trace("mouseLeave");
if(_backgroundDragInProgress) {
dragEnd(null);
}
}
5) VisualGraph.as - This is what my dragEnd() function looks like (around line
1940):
...
if(_backgroundDragInProgress) {
// If it was a background drag we stop it here.
_backgroundDragInProgress = false;
// Get the background drag object, which is usually the canvas.
if (event) {
myback = (event.currentTarget as DisplayObject);
// Unregister event handler.
myback.removeEventListener(MouseEvent.MOUSE_MOVE,backgroundDragContinue);
} else {
// This can happen if we let go of the button outside of the window.
trace("dragEnd: background drop event target was not Canvas.");
}
//myback.removeEventListener(MouseEvent.MOUSE_MOVE,dragEnd);
// Issue #32 BUG fix.
_canvas.removeEventListener(MouseEvent.MOUSE_MOVE, backgroundDragContinue);
// And inform the layouter about the dropEvent.
_layouter.bgDropEvent(event);
} else {
...
Original comment by nick.jg....@gmail.com
on 12 Jul 2008 at 1:33
Original issue reported on code.google.com by
AndrijSk...@gmail.com
on 20 Apr 2008 at 9:00