Lua - implement forms.addclick() and forms.clearclicks()

This commit is contained in:
andres.delikat 2012-07-10 22:52:06 +00:00
parent 04273ec3ee
commit 3f81bc9cdb
1 changed files with 61 additions and 0 deletions

View File

@ -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<LuaWinform.Lua_Event> 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 "";
}
}
}