From 3f81bc9cdb7b771e8c69b4f05c4e7aed59f1ee47 Mon Sep 17 00:00:00 2001 From: "andres.delikat" Date: Tue, 10 Jul 2012 22:52:06 +0000 Subject: [PATCH] Lua - implement forms.addclick() and forms.clearclicks() --- BizHawk.MultiClient/LuaImplementation.cs | 61 ++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/BizHawk.MultiClient/LuaImplementation.cs b/BizHawk.MultiClient/LuaImplementation.cs index 942fd23c03..c319d6a8f1 100644 --- a/BizHawk.MultiClient/LuaImplementation.cs +++ b/BizHawk.MultiClient/LuaImplementation.cs @@ -417,6 +417,9 @@ namespace BizHawk.MultiClient "setlocation", "setsize", "settext", + "addclick", + "clearclicks", + "gettext", }; /****************************************************/ @@ -1876,5 +1879,63 @@ namespace BizHawk.MultiClient } } } + + public void forms_addclick(object handle, LuaFunction lua_event) + { + IntPtr ptr = new IntPtr(LuaInt(handle)); + foreach (LuaWinform form in LuaForms) + { + foreach (Control control in form.Controls) + { + if (control.Handle == ptr) + { + form.Control_Events.Add(new LuaWinform.Lua_Event(control.Handle, lua_event)); + } + } + } + } + + public void forms_clearclicks(object handle) + { + IntPtr ptr = new IntPtr(LuaInt(handle)); + foreach (LuaWinform form in LuaForms) + { + foreach (Control control in form.Controls) + { + if (control.Handle == ptr) + { + List lua_events = form.Control_Events.Where(x => x.Control == ptr).ToList(); + foreach (LuaWinform.Lua_Event levent in lua_events) + { + form.Control_Events.Remove(levent); + } + } + } + } + } + + public string forms_gettext(object handle) + { + IntPtr ptr = new IntPtr(LuaInt(handle)); + foreach (LuaWinform form in LuaForms) + { + if (form.Handle == ptr) + { + return form.Text; + } + else + { + foreach (Control control in form.Controls) + { + if (control.Handle == ptr) + { + return control.Text; + } + } + } + } + + return ""; + } } }