Explorar o código

use Reflect.compareMethods instead of == (in case of array of closures)

Nicolas Cannasse %!s(int64=8) %!d(string=hai) anos
pai
achega
45f1115f86
Modificáronse 3 ficheiros con 22 adicións e 4 borrados
  1. 6 1
      h2d/Scene.hx
  2. 10 2
      hxd/Stage.hx
  3. 6 1
      hxd/WaitEvent.hx

+ 6 - 1
h2d/Scene.hx

@@ -246,7 +246,12 @@ class Scene extends Layers implements h3d.IDrawable implements hxd.SceneEvents.I
 	}
 
 	public function removeEventListener( f : hxd.Event -> Void ) {
-		return eventListeners.remove(f);
+		for( e in eventListeners )
+			if( Reflect.compareMethods(e, f) ) {
+				eventListeners.remove(e);
+				return true;
+			}
+		return false;
 	}
 
 	public function startDrag( f : hxd.Event -> Void, ?onCancel : Void -> Void, ?refEvent : hxd.Event ) {

+ 10 - 2
hxd/Stage.hx

@@ -139,7 +139,11 @@ class Stage {
 	}
 
 	public function removeEventTarget(et) {
-		eventTargets.remove(et);
+		for( e in eventTargets )
+			if( Reflect.compareMethods(e,et) ) {
+				eventTargets.remove(e);
+				break;
+			}
 	}
 
 	public function addResizeEvent( f : Void -> Void ) {
@@ -147,7 +151,11 @@ class Stage {
 	}
 
 	public function removeResizeEvent( f : Void -> Void ) {
-		resizeEvents.remove(f);
+		for( e in resizeEvents )
+			if( Reflect.compareMethods(e,f) ) {
+				resizeEvents.remove(f);
+				break;
+			}
 	}
 
 	function onResize(e:Dynamic) {

+ 6 - 1
hxd/WaitEvent.hx

@@ -21,7 +21,12 @@ class WaitEvent {
 	}
 
 	public function remove(callb) {
-		updateList.remove(callb);
+		for( e in updateList )
+			if( Reflect.compareMethods(e, callb) ) {
+				updateList.remove(e);
+				return true;
+			}
+		return false;
 	}
 
 	public function wait( time : Float, callb ) {