Set `Form.Owner` to MainForm for Lua-made forms

This commit is contained in:
YoshiRulz 2022-07-15 22:26:08 +10:00
parent 3fddcdb2c5
commit 94e85f1079
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
2 changed files with 7 additions and 0 deletions

View File

@ -17,6 +17,8 @@ namespace BizHawk.Client.EmuHawk
public FormsLuaLibrary(IPlatformLuaLibEnv luaLibsImpl, ApiContainer apiContainer, Action<string> logOutputCallback)
: base(luaLibsImpl, apiContainer, logOutputCallback) {}
public Form MainForm { get; set; }
public override string Name => "forms";
private readonly List<LuaWinform> _luaForms = new List<LuaWinform>();
@ -352,6 +354,7 @@ namespace BizHawk.Client.EmuHawk
form.MaximizeBox = false;
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.Icon = SystemIcons.Application;
form.Owner = MainForm;
form.Show();
form.FormClosed += (o, e) =>

View File

@ -96,6 +96,10 @@ namespace BizHawk.Client.EmuHawk
consoleLib.Tools = _mainForm.Tools;
_logToLuaConsoleCallback = consoleLib.Log;
}
else if (instance is FormsLuaLibrary formsLib)
{
formsLib.MainForm = _mainForm;
}
else if (instance is GuiLuaLibrary guiLib)
{
// emu lib may be null now, depending on order of ReflectionCache.Types, but definitely won't be null when this is called