]> O.S.I.I.S - jp/crow.git/commitdiff
Hack hostClass to have it point to main window when custom class is
authorjpbruyere <jp.bruyere@hotmail.com>
Thu, 10 Sep 2015 23:12:04 +0000 (01:12 +0200)
committerjpbruyere <jp.bruyere@hotmail.com>
Thu, 10 Sep 2015 23:12:04 +0000 (01:12 +0200)
passed as data source

src/Interface.cs

index 69e8d9d0bee8b4559145b23a6a233e766589225a..9b6e3dc8291bccb84806cd29a6da39dee64e3fdf 100644 (file)
@@ -175,14 +175,21 @@ namespace go
                                                MethodInfo mi = hostClass.GetType ().GetMethod (es.Value, BindingFlags.NonPublic | BindingFlags.Public
                                                                | BindingFlags.Instance);
 
+                                               object effectiveHostClass = hostClass;
                                                if (mi == null) {
-                                                       Debug.WriteLine ("Handler Method not found: " + es.Value);
-                                                       continue;
+                                                       //TODO: hack to have it work, hostClass and dataSource should be clearly separated
+                                                       mi = OpenTKGameWindow.currentWindow.GetType ().GetMethod (es.Value, BindingFlags.NonPublic | BindingFlags.Public
+                                                               | BindingFlags.Instance);
+                                                       if (mi == null) {
+                                                               Debug.WriteLine ("Handler Method not found: " + es.Value);
+                                                               continue;
+                                                       }
+                                                       effectiveHostClass = OpenTKGameWindow.currentWindow;
                                                }
 
                                                EventInfo ei = es.Source.GetType ().GetEvent (es.MemberName);
                                                MethodInfo addHandler = ei.GetAddMethod ();
-                                               Delegate del = Delegate.CreateDelegate (ei.EventHandlerType, hostClass, mi);
+                                               Delegate del = Delegate.CreateDelegate (ei.EventHandlerType, effectiveHostClass, mi);
 
 
                                                addHandler.Invoke(es.Source, new object[] {del});