Auar / flexvizgraphlib

Automatically exported from code.google.com/p/flexvizgraphlib
0 stars 0 forks source link

Panning background over external to VisualGraph components #29

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Steps that will reproduce the problem:
1. Click on background area on VisualGraph component
2. Start to drag background (use panning). Graph area will start drag.
3. Move mouse over external control (f.e. accordion)
4. End drag process (mouse key up) over external control
5. Try to move mouse over graph. Drag process (panning) not finished. Graph
 still move after mouse.

Expected output is to end panning process (like it works when user finish
it over graph (not over external control)).

My version is SVN revision 312.
OS: Windows XP SP2

Original issue reported on code.google.com by AndrijSk...@gmail.com on 20 Apr 2008 at 9:00

GoogleCodeExporter commented 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

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
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