mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
feat: improve focus behavior
This commit is contained in:
@@ -213,11 +213,21 @@ namespace GHelper
|
|||||||
SetAutoModes(true);
|
SetAutoModes(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static void SettingsToggle(string action = "")
|
public static void SettingsToggle(string action = "")
|
||||||
{
|
{
|
||||||
if (settingsForm.Visible) settingsForm.HideAll();
|
if (settingsForm.Visible)
|
||||||
|
{
|
||||||
|
// If helper window is not on top, this just focuses on the app again
|
||||||
|
// Pressing the ghelper button again will hide the app
|
||||||
|
if (!settingsForm.HasAnyFocus())
|
||||||
|
{
|
||||||
|
settingsForm.ShowAll();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
settingsForm.HideAll();
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -279,5 +289,4 @@ namespace GHelper
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -847,6 +847,27 @@ namespace GHelper
|
|||||||
if (updates != null && updates.Text != "") updates.Close();
|
if (updates != null && updates.Text != "") updates.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Brings all visible windows to the top, with settings being the focus
|
||||||
|
/// <br/>
|
||||||
|
/// Note: this will not respect previous focus i.e. will always focus settings
|
||||||
|
/// </summary>
|
||||||
|
public void ShowAll()
|
||||||
|
{
|
||||||
|
if (fans != null && fans.Visible) fans.Activate();
|
||||||
|
if (keyb != null && keyb.Visible) keyb.Activate();
|
||||||
|
if (updates != null && updates.Visible) updates.Activate();
|
||||||
|
this.Activate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if any of fans, keyboard, update, or itself has focus
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Focus state</returns>
|
||||||
|
public bool HasAnyFocus()
|
||||||
|
{
|
||||||
|
return (fans != null && fans.ContainsFocus) || (keyb != null && keyb.ContainsFocus) || (updates != null && updates.ContainsFocus) || this.ContainsFocus;
|
||||||
|
}
|
||||||
|
|
||||||
private void SettingsForm_FormClosing(object? sender, FormClosingEventArgs e)
|
private void SettingsForm_FormClosing(object? sender, FormClosingEventArgs e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user