Skip to content

Commit

Permalink
added incremental selection if SHIFT is pressed
Browse files Browse the repository at this point in the history
  • Loading branch information
MoritzStefaner committed Jul 6, 2011
1 parent 5077c8f commit 39fb872
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion flare/src/flare/vis/controls/SelectionControl.as
@@ -1,14 +1,14 @@
package flare.vis.controls
{
import flare.vis.events.SelectionEvent;

import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.Graphics;
import flash.display.InteractiveObject;
import flash.display.Shape;
import flash.display.Stage;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.geom.Rectangle;
import flash.utils.Dictionary;
Expand All @@ -22,6 +22,7 @@ package flare.vis.controls
*/
public class SelectionControl extends Control
{
private static var SHIFT_DOWN : Boolean;
protected var _r:Rectangle = new Rectangle();
protected var _drag:Boolean = false;
protected var _shape:Shape = new Shape();
Expand Down Expand Up @@ -121,6 +122,8 @@ package flare.vis.controls
_object.removeEventListener(Event.REMOVED_FROM_STAGE, onRemove);
}
_hit = null;
_stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
_stage.removeEventListener(KeyboardEvent.KEY_UP, keyReleased);
return super.detach();
}

Expand All @@ -129,6 +132,16 @@ package flare.vis.controls
_stage = _object.stage;
if (_hit == null) _hit = _stage;
_hit.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown);
_stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
_stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
}

private function keyReleased(event : KeyboardEvent) : void {
if (event.keyCode == 16) SHIFT_DOWN = false;
}

private function keyPressed(event : KeyboardEvent) : void {
if (event.keyCode == 16) SHIFT_DOWN = true;
}

protected function onRemove(evt:Event=null):void
Expand Down Expand Up @@ -244,6 +257,9 @@ package flare.vis.controls
}

protected function deselect(d:DisplayObject):void {
// no deselection if shift is pressed
if(SHIFT_DOWN) return;

delete _sel[d];
if (_rem == null)
if (_rem0 == null) {
Expand Down

0 comments on commit 39fb872

Please sign in to comment.