mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Merge pull request #1407 from nopeless/main
feat: improve focus behavior
This commit is contained in:
@@ -337,7 +337,7 @@ namespace GHelper.Input
|
||||
if (e.Modifier == (ModifierKeys.Control | ModifierKeys.Shift))
|
||||
{
|
||||
if (e.Key == keyProfile) modeControl.CyclePerformanceMode();
|
||||
if (e.Key == keyApp) Program.SettingsToggle();
|
||||
if (e.Key == keyApp) Program.SettingsToggle("", true);
|
||||
if (e.Key == Keys.F20) KeyProcess("m3");
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ namespace GHelper.Input
|
||||
{
|
||||
Program.settingsForm.BeginInvoke(delegate
|
||||
{
|
||||
Program.SettingsToggle();
|
||||
Program.SettingsToggle("", true);
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -213,11 +213,21 @@ namespace GHelper
|
||||
SetAutoModes(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void SettingsToggle(string action = "")
|
||||
public static void SettingsToggle(string action = "", bool checkForFocus = false)
|
||||
{
|
||||
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 (checkForFocus && !settingsForm.HasAnyFocus())
|
||||
{
|
||||
settingsForm.ShowAll();
|
||||
}
|
||||
else
|
||||
{
|
||||
settingsForm.HideAll();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -279,5 +289,4 @@ namespace GHelper
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -547,6 +547,7 @@ namespace GHelper
|
||||
if (matrix == null || matrix.Text == "")
|
||||
{
|
||||
matrix = new Matrix();
|
||||
AddOwnedForm(matrix);
|
||||
}
|
||||
|
||||
if (matrix.Visible)
|
||||
@@ -615,6 +616,7 @@ namespace GHelper
|
||||
{
|
||||
keyb = new Extra();
|
||||
keyb.Show();
|
||||
AddOwnedForm(keyb);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -643,6 +645,7 @@ namespace GHelper
|
||||
if (fans == null || fans.Text == "")
|
||||
{
|
||||
fans = new Fans();
|
||||
AddOwnedForm(fans);
|
||||
}
|
||||
|
||||
if (fans.Visible)
|
||||
@@ -839,6 +842,9 @@ namespace GHelper
|
||||
Application.Exit();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes all forms except the settings. Hides the settings
|
||||
/// </summary>
|
||||
public void HideAll()
|
||||
{
|
||||
this.Hide();
|
||||
@@ -847,6 +853,22 @@ namespace GHelper
|
||||
if (updates != null && updates.Text != "") updates.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Brings all visible windows to the top, with settings being the focus
|
||||
/// </summary>
|
||||
public void ShowAll()
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user