HOtkeys dialog - focus on first input widget when changing tabs. However does not work on load because winform events suck

This commit is contained in:
adelikat 2013-08-04 20:51:49 +00:00
parent 4e234072eb
commit 8e8cf4a8fe
2 changed files with 28 additions and 0 deletions

View File

@ -72,6 +72,8 @@
this.HotkeyTabControl.SelectedIndex = 0;
this.HotkeyTabControl.Size = new System.Drawing.Size(729, 394);
this.HotkeyTabControl.TabIndex = 102;
this.HotkeyTabControl.SelectedIndexChanged += new System.EventHandler(this.HotkeyTabControl_SelectedIndexChanged);
this.HotkeyTabControl.Enter += new System.EventHandler(this.HotkeyTabControl_Enter);
//
// tabPage1
//

View File

@ -20,6 +20,7 @@ namespace BizHawk.MultiClient
{
AutoTabCheckBox.Checked = Global.Config.HotkeyConfigAutoTab;
DoTabs();
DoFocus();
}
private void IDB_CANCEL_Click(object sender, EventArgs e)
@ -144,5 +145,30 @@ namespace BizHawk.MultiClient
w.AutoTab = AutoTabCheckBox.Checked;
}
}
private void HotkeyTabControl_SelectedIndexChanged(object sender, EventArgs e)
{
DoFocus();
}
private void DoFocus()
{
if (HotkeyTabControl.SelectedTab != null)
{
foreach (Control c in HotkeyTabControl.SelectedTab.Controls)
{
if (c is InputWidget)
{
(c as InputWidget).Focus();
return;
}
}
}
}
private void HotkeyTabControl_Enter(object sender, EventArgs e)
{
DoFocus();
}
}
}