Преглед изворни кода

added virtual mouse configuration

bstouls пре 6 година
родитељ
комит
d85793758a
1 измењених фајлова са 17 додато и 1 уклоњено
  1. 17 1
      hxd/SceneEvents.hx

+ 17 - 1
hxd/SceneEvents.hx

@@ -33,6 +33,16 @@ class SceneEvents {
 	var onOut = new hxd.Event(EOut);
 	var isOut = false;
 
+	/**
+	 * enablePhysicalMouse : enable mouse movements of system mouse, set it to false anse use setMousePos instead to manually set mouse position
+	 */
+	public var enablePhysicalMouse = true;
+
+	/**
+	 * enable/disable per frame check of elements under mouse (default:true)
+	 */
+	public var mouseCheckMove = true;
+
 	public function new( ?window ) {
 		scenes = [];
 		pendingEvents = [];
@@ -42,6 +52,11 @@ class SceneEvents {
 		window.addEventTarget(onEvent);
 	}
 
+	public function setMousePos( xPos, yPos ) {
+		mouseX = xPos;
+		mouseY = yPos;
+	}
+
 	function onRemove(i) {
 		if( i == currentFocus )
 			currentFocus = null;
@@ -224,7 +239,7 @@ class SceneEvents {
 
 	public function checkEvents() {
 		var old = pendingEvents;
-		var checkMoved = false;
+		var checkMoved = !mouseCheckMove;
 		var checkFocused = currentFocus == null;
 		if( old.length > 0 ) {
 			pendingEvents = [];
@@ -308,6 +323,7 @@ class SceneEvents {
 	}
 
 	function onEvent( e : hxd.Event ) {
+		if( !enablePhysicalMouse && e.kind == EMove ) return;
 		pendingEvents.push(e);
 	}