From: Richard Fairhurst Date: Tue, 27 Dec 2011 16:17:10 +0000 (+0000) Subject: Improve mouseup/mousedown behaviour when dragging: X-Git-Url: https://git.openstreetmap.org/potlatch2.git/commitdiff_plain/f0d24f7964b9ea9dd3a982cdf796202d035816a1 Improve mouseup/mousedown behaviour when dragging: 1. if browser doesn't send mouseup when the mouse is outside the window (as per Safari), allow a simple click to stop the drag 2. don't drag-and-drop POIs when dragging the map --- diff --git a/net/systemeD/halcyon/Map.as b/net/systemeD/halcyon/Map.as index 3902f367..3d3e9497 100644 --- a/net/systemeD/halcyon/Map.as +++ b/net/systemeD/halcyon/Map.as @@ -64,6 +64,7 @@ package net.systemeD.halcyon { public const NOT_DRAGGING:uint=0; // | public const NOT_MOVED:uint=1; // | public const DRAGGING:uint=2; // | + public const SWALLOW_MOUSEUP:uint=3; // | /** How far the map can be dragged without actually triggering a pan. */ public const TOLERANCE:uint=7; // | @@ -389,7 +390,8 @@ package net.systemeD.halcyon { /** Prepare for being dragged by recording start time and location of mouse. */ public function mouseDownHandler(event:MouseEvent):void { if (!_draggable) { return; } - dragstate=NOT_MOVED; + if (dragstate==DRAGGING) { moveMap(x,y); dragstate=SWALLOW_MOUSEUP; } // cancel drag if mouse-up occurred outside the window (thanks, Safari) + else { dragstate=NOT_MOVED; } lastxmouse=stage.mouseX; downX=stage.mouseX; lastymouse=stage.mouseY; downY=stage.mouseY; downTime=new Date().getTime(); diff --git a/net/systemeD/potlatch2/TagViewer.mxml b/net/systemeD/potlatch2/TagViewer.mxml index 9c8ae323..03593725 100644 --- a/net/systemeD/potlatch2/TagViewer.mxml +++ b/net/systemeD/potlatch2/TagViewer.mxml @@ -32,6 +32,8 @@ import mx.core.DragSource; private function dragPOI(event:MouseEvent, tags:Array):void { + if (outerDocument.controller.map.dragstate==outerDocument.controller.map.DRAGGING) return; + // Get the drag initiator component from the event object. var dragInitiator:Image = event.currentTarget as Image; var dragSource:DragSource = new DragSource(); diff --git a/net/systemeD/potlatch2/controller/NoSelection.as b/net/systemeD/potlatch2/controller/NoSelection.as index b780bd25..873ddb8a 100644 --- a/net/systemeD/potlatch2/controller/NoSelection.as +++ b/net/systemeD/potlatch2/controller/NoSelection.as @@ -23,7 +23,7 @@ package net.systemeD.potlatch2.controller { var paint:MapPaint = getMapPaint(DisplayObject(event.target)); var focus:Entity = getTopLevelFocusEntity(entity); - if (event.type==MouseEvent.MOUSE_UP && (focus==null || (paint && paint.isBackground)) && map.dragstate!=map.DRAGGING) { + if (event.type==MouseEvent.MOUSE_UP && (focus==null || (paint && paint.isBackground)) && map.dragstate!=map.DRAGGING && map.dragstate!=map.SWALLOW_MOUSEUP) { map.dragstate=map.NOT_DRAGGING; // ** FIXME: BeginWayAction ought to be a discrete class var undo:CompositeUndoableAction = new BeginWayAction();