import flash.geom.Point;
import flash.ui.Keyboard;
import net.systemeD.potlatch2.EditController;
+ import net.systemeD.halcyon.MapPaint;
import net.systemeD.halcyon.connection.*;
import net.systemeD.halcyon.connection.actions.*;
private var downX:Number;
private var downY:Number;
private var dragstate:uint=NOT_MOVED;
+ private var initialMouseEvent:MouseEvent;
+ private var wayList:Array;
/** Not used? */
private const NOT_DRAGGING:uint=0;
private const DRAGGING:uint=2;
/** Start the drag by recording the dragged way, where it started, and when. */
- public function DragSelection(sel:Array, event:MouseEvent) {
+ public function DragSelection(sel:Array, event:MouseEvent, ways:Array = null) {
selection = sel.concat();
downX = event.localX;
downY = event.localY;
+ wayList = ways;
enterTime = (new Date()).getTime();
+ initialMouseEvent = event;
}
/** Handle dragging and end drag events. Filters out very short or quick drags. */
/** Abort dragging if ESC pressed. */
override public function processKeyboardEvent(event:KeyboardEvent):ControllerState {
+ if (event.keyCode==Keyboard.SPACE) { return cycleAllWays(initialMouseEvent); }
if (event.keyCode==Keyboard.ESCAPE) {
for each (var entity:Entity in selection) {
entity.dispatchEvent(new EntityDraggedEvent(Connection.ENTITY_DRAGGED, entity, 0, 0));
dragstate=NOT_MOVED;
}
+ private function cycleAllWays(event:MouseEvent):ControllerState {
+ trace("cycleAllWays");
+ if (!(downX && downY) || (wayList && wayList.length<2) || selection.length != 1) { return this; }
+ trace("cycleAllWays2");
+ if (!wayList) {
+ wayList=selection
+ for each (var l:MapPaint in controller.map.getLayers()) {
+ trace("Layer "+l.connection.name);
+ trace(l.findWaysAtPoint(event.stageX, event.stageY).length);
+ wayList = wayList.concat(l.findWaysAtPoint(event.stageX, event.stageY,selection[0]));
+ }
+ }
+ for each (var way:Way in wayList) {
+ trace(way + "::" + way.connection.name);
+ }
+ wayList=wayList.slice(1).concat(wayList[0]);
+ // Find the new way's index of the currently "selected" node, to facilitate keyboard navigation
+ return new DragSelection([wayList[0]], event, wayList);
+ }
+
/** Highlight the dragged selection. */
override public function enterState():void {
for each (var entity:Entity in selection) {