Fix #3087 hotkeys triggering accidentally in Virtual Pad but on Win

This commit is contained in:
YoshiRulz 2022-05-07 17:11:34 +10:00
parent b7ffa811bf
commit 5f820cc530
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
1 changed files with 13 additions and 4 deletions

View File

@ -24,7 +24,15 @@ namespace BizHawk.Client.EmuHawk
private Control _lastFocusedNUD = null;
public override bool BlocksInputWhenFocused => _lastFocusedNUD?.Focused == true;
public override bool BlocksInputWhenFocused
{
get
{
// >:( `NumericUpDown.Focused` doesn't work on Windows (the REFERENCE IMPLEMENTATION), a fact that goes UNMENTIONED in the docs https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.updownbase.focused?view=netframework-4.8
if (!OSTailoredCode.IsUnixHost) return true; // ...and I can't think of another hack that isn't extremely convoluted, so the Virtual Pad can just block all input. --yoshi
return _lastFocusedNUD?.Focused is true; // on Mono, simple hack to check if typing in a NUD
}
}
private List<VirtualPad> Pads =>
ControllerPanel.Controls
@ -114,9 +122,10 @@ namespace BizHawk.Client.EmuHawk
}
}
void SetLastFocusedNUD(object sender, EventArgs args)
=> _lastFocusedNUD = (Control) sender;
ControllerPanel.Controls.AddRange(padSchemata.Select(s => (Control) new VirtualPad(s, InputManager, SetLastFocusedNUD)).Reverse().ToArray());
EventHandler setLastFocusedNUD = OSTailoredCode.IsUnixHost
? (sender, _) => _lastFocusedNUD = (Control) sender
: (_, _) => {}; // see BlocksInputWhenFocused implementation
ControllerPanel.Controls.AddRange(padSchemata.Select(s => (Control) new VirtualPad(s, InputManager, setLastFocusedNUD)).Reverse().ToArray());
}
public void ScrollToPadSchema(string padSchemaName)