Forráskód Böngészése

handle window enter/leave resetting hover interactive

ncannasse 6 éve
szülő
commit
c179b3424a
2 módosított fájl, 19 hozzáadás és 1 törlés
  1. 15 1
      hxd/SceneEvents.hx
  2. 4 0
      hxd/Window.hl.hx

+ 15 - 1
hxd/SceneEvents.hx

@@ -31,6 +31,7 @@ class SceneEvents {
 	var focusLost = new hxd.Event(EFocusLost);
 	var checkPos = new hxd.Event(ECheck);
 	var onOut = new hxd.Event(EOut);
+	var isOut = false;
 
 	public function new( ?window ) {
 		scenes = [];
@@ -246,6 +247,19 @@ class SceneEvents {
 						checkFocused = true;
 						checkFocus();
 					}
+				case EOver:
+					isOut = false;
+					continue;
+				case EOut:
+					// leave window
+					isOut = true;
+					if( currentOver != null ) {
+						onOut.cancel = false;
+						currentOver.handleEvent(onOut);
+						if( !onOut.cancel )
+							currentOver = null;
+					}
+					continue;
 				default:
 				}
 
@@ -269,7 +283,7 @@ class SceneEvents {
 		if( !checkFocused )
 			checkFocus();
 
-		if( !checkMoved && currentDrag == null ) {
+		if( !checkMoved && !isOut && currentDrag == null ) {
 			checkPos.relX = mouseX;
 			checkPos.relY = mouseY;
 			checkPos.touchId = lastTouch;

+ 4 - 0
hxd/Window.hl.hx

@@ -164,6 +164,10 @@ class Window {
 						event(ev);
 					}
 				#end
+			case Enter:
+				event(new Event(EOver));
+			case Leave:
+				event(new Event(EOut));
 			default:
 			}
 		case MouseDown: