Browse Source

dispatch key/wheel events to current over element and propagate to listeners by default

ncannasse 11 năm trước cách đây
mục cha
commit
504e140430
2 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 1 1
      h2d/Interactive.hx
  2. 7 1
      h2d/Scene.hx

+ 1 - 1
h2d/Interactive.hx

@@ -66,7 +66,7 @@ class Interactive extends Drawable {
 				return;
 			}
 		}
-		e.propagate = propagateEvents;
+		if( propagateEvents ) e.propagate = true;
 		if( !blockEvents ) e.cancel = true;
 		switch( e.kind ) {
 		case EMove:

+ 7 - 1
h2d/Scene.hx

@@ -101,8 +101,14 @@ class Scene extends Layers implements h3d.IDrawable {
 		case EKeyUp, EKeyDown, EWheel:
 			if( currentFocus != null )
 				currentFocus.handleEvent(event);
-			else
+			else {
+				if( currentOver != null ) {
+					event.propagate = true;
+					currentOver.handleEvent(event);
+					if( !event.propagate ) return;
+				}
 				dispatchListeners(event);
+			}
 			return;
 		default:
 		}