diff options
| author | jpbruyere <jp.bruyere@hotmail.com> | 2015-09-11 01:12:04 +0200 |
|---|---|---|
| committer | jpbruyere <jp.bruyere@hotmail.com> | 2015-09-11 01:12:04 +0200 |
| commit | 53457ed25ba3f8d7535ddc9f2c0c7d3c04b8fdce (patch) | |
| tree | 5aa19c25730b1a484e7df5ad9e632e00e4cfc2a2 /src/Interface.cs | |
| parent | 6f3b4f69ff27623bd94454514e024adf5893503b (diff) | |
Hack hostClass to have it point to main window when custom class is
passed as data source
Diffstat (limited to 'src/Interface.cs')
| -rw-r--r-- | src/Interface.cs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/Interface.cs b/src/Interface.cs index 69e8d9d0..9b6e3dc8 100644 --- a/src/Interface.cs +++ b/src/Interface.cs @@ -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}); |