summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <okay@toyful.space>2021-02-17 10:39:53 -0600
committerColin Okay <okay@toyful.space>2021-02-17 10:39:53 -0600
commitaaa7a5171d8d6e5c5d01cdbba1fb2adcd6e21adb (patch)
tree9825431d6da10e10b774cd0e906b0407274c4e8f
parente4239744176f8f9790eb7dbb48987535698ada76 (diff)
hadnling resize
-rw-r--r--Source/Main.hx30
1 files changed, 23 insertions, 7 deletions
diff --git a/Source/Main.hx b/Source/Main.hx
index 3bb4de7..ee33608 100644
--- a/Source/Main.hx
+++ b/Source/Main.hx
@@ -612,7 +612,7 @@ class DrawingScreen extends Sprite
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
addEventListener(MouseEvent.MOUSE_OUT, onMouseUp);
addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
- addEventListener(Event.ADDED_TO_STAGE, maximizeHitArea);
+ addEventListener(Event.ADDED_TO_STAGE, addedToStage);
}
/* Event Handling */
@@ -624,13 +624,29 @@ class DrawingScreen extends Sprite
var drawing = false;
var timestamp:Float;
- function maximizeHitArea(e)
+ function addedToStage (e)
{
- var hitBox = new Sprite();
- hitBox.graphics.beginFill(0);
- hitBox.graphics.drawRect( 0, 0, stage.stageWidth, stage.stageHeight);
- hitBox.mouseEnabled = false;
- this.hitArea = hitBox;
+ maximizeHitArea();
+ stage.addEventListener(Event.RESIZE, (e) -> maximizeHitArea());
+ }
+
+ function maximizeHitArea()
+ {
+ if (this.hitArea == null)
+ {
+ var hitBox = new Sprite();
+ hitBox.graphics.beginFill(0);
+ hitBox.graphics.drawRect( 0, 0, stage.stageWidth, stage.stageHeight);
+ hitBox.mouseEnabled = false;
+ this.hitArea = hitBox;
+ }
+ else
+ {
+ this.hitArea.graphics.clear();
+ this.hitArea.graphics.beginFill(0);
+ this.hitArea.graphics.drawRect( 0, 0, stage.stageWidth, stage.stageHeight);
+ this.hitArea.mouseEnabled = false;
+ }
}
function onMouseDown (e)