summaryrefslogtreecommitdiff
path: root/src/SMAPI
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-02-18 22:40:20 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-02-18 22:40:20 -0500
commit033015066650d4bd67a7df0a7f7addf4c6edf617 (patch)
tree94ba2cf7229ec2401eb17d9f91716632d9b4a3e8 /src/SMAPI
parent25cf3a86cf159aaef2f0de78a24d9d074a0bedf2 (diff)
downloadSMAPI-033015066650d4bd67a7df0a7f7addf4c6edf617.tar.gz
SMAPI-033015066650d4bd67a7df0a7f7addf4c6edf617.tar.bz2
SMAPI-033015066650d4bd67a7df0a7f7addf4c6edf617.zip
suppress keyboard events when a textbox is focused (#445)
Diffstat (limited to 'src/SMAPI')
-rw-r--r--src/SMAPI/Framework/SGame.cs22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/SMAPI/Framework/SGame.cs b/src/SMAPI/Framework/SGame.cs
index e82ee778..f080f3c5 100644
--- a/src/SMAPI/Framework/SGame.cs
+++ b/src/SMAPI/Framework/SGame.cs
@@ -256,7 +256,7 @@ namespace StardewModdingAPI.Framework
this.Monitor.Log("Context: before save creation.", LogLevel.Trace);
SaveEvents.InvokeBeforeCreate(this.Monitor);
}
-
+
// raise before-save
if (Context.IsWorldReady && !this.IsBetweenSaveEvents)
{
@@ -386,20 +386,23 @@ namespace StardewModdingAPI.Framework
}
// raise input events
+ bool isTextboxReceiving = Game1.keyboardDispatcher?.Subscriber?.Selected == true;
foreach (var pair in inputState.ActiveButtons)
{
SButton button = pair.Key;
InputStatus status = pair.Value;
+ bool isKeyboard = button.TryGetKeyboard(out Keys keyboardKey);
if (status == InputStatus.Pressed)
{
- InputEvents.InvokeButtonPressed(this.Monitor, button, cursor, button.IsActionButton(), button.IsUseToolButton());
+ if (!isTextboxReceiving || !isKeyboard)
+ InputEvents.InvokeButtonPressed(this.Monitor, button, cursor, button.IsActionButton(), button.IsUseToolButton());
// legacy events
- if (button.TryGetKeyboard(out Keys key))
+ if (isKeyboard)
{
- if (key != Keys.None)
- ControlEvents.InvokeKeyPressed(this.Monitor, key);
+ if (!isTextboxReceiving && keyboardKey != Keys.None)
+ ControlEvents.InvokeKeyPressed(this.Monitor, keyboardKey);
}
else if (button.TryGetController(out Buttons controllerButton))
{
@@ -411,13 +414,14 @@ namespace StardewModdingAPI.Framework
}
else if (status == InputStatus.Released)
{
- InputEvents.InvokeButtonReleased(this.Monitor, button, cursor, button.IsActionButton(), button.IsUseToolButton());
+ if (!isTextboxReceiving || !isKeyboard)
+ InputEvents.InvokeButtonReleased(this.Monitor, button, cursor, button.IsActionButton(), button.IsUseToolButton());
// legacy events
- if (button.TryGetKeyboard(out Keys key))
+ if (isKeyboard)
{
- if (key != Keys.None)
- ControlEvents.InvokeKeyReleased(this.Monitor, key);
+ if (!isTextboxReceiving && keyboardKey != Keys.None)
+ ControlEvents.InvokeKeyReleased(this.Monitor, keyboardKey);
}
else if (button.TryGetController(out Buttons controllerButton))
{