diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0131c57..d5d48cc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,7 +20,7 @@ Additions
- Added UniformTextureAtlas methods ToList and ToDictionary
- Added SingleRandom and SeedSource
- Added TokenizedString.GetArea
-- Added InputHandler.WasPressedForLess and related methods
+- Added InputHandler.WasPressedForLess and related methods as well as InputHandler.IsPressedIgnoreRepeats
- **Added the ability to find paths to one of multiple goals using AStar**
Improvements
@@ -49,6 +49,7 @@ Removals
- Marked EnumHelper as obsolete due to its reimplementation in [DynamicEnums](https://www.nuget.org/packages/DynamicEnums)
- Marked Code.GetReplacementString as obsolete
- Marked TokenizedString.Measure as obsolete in favor of GetArea
+- Marked non-GenericInput versions of IsDown, IsUp, IsPressed and related methods as obsolete in favor of GenericInput ones
### MLEM.Ui
Additions
diff --git a/MLEM.Ui/Elements/ScrollBar.cs b/MLEM.Ui/Elements/ScrollBar.cs
index e0fef5c..6fce5bc 100644
--- a/MLEM.Ui/Elements/ScrollBar.cs
+++ b/MLEM.Ui/Elements/ScrollBar.cs
@@ -147,8 +147,8 @@ namespace MLEM.Ui.Elements {
// MOUSE INPUT
var moused = this.Controls.MousedElement;
- var wasMouseUp = this.Input.WasMouseButtonUp(MouseButton.Left);
- var isMouseDown = this.Input.IsMouseButtonDown(MouseButton.Left);
+ var wasMouseUp = this.Input.WasUp(MouseButton.Left);
+ var isMouseDown = this.Input.IsDown(MouseButton.Left);
if (moused == this && wasMouseUp && isMouseDown) {
this.isMouseScrolling = true;
this.scrollStartOffset = this.TransformInverseAll(this.Input.ViewportMousePosition.ToVector2()) - this.ScrollerPosition;
diff --git a/MLEM.Ui/UiControls.cs b/MLEM.Ui/UiControls.cs
index e2d7a25..e4689cd 100644
--- a/MLEM.Ui/UiControls.cs
+++ b/MLEM.Ui/UiControls.cs
@@ -165,19 +165,19 @@ namespace MLEM.Ui {
var mousedNow = this.GetElementUnderPos(new Vector2(this.Input.ViewportMousePosition.X, this.Input.ViewportMousePosition.Y));
this.SetMousedElement(mousedNow);
- if (this.Input.IsMouseButtonPressedAvailable(MouseButton.Left)) {
+ if (this.Input.IsPressedAvailable(MouseButton.Left)) {
this.IsAutoNavMode = false;
var selectedNow = mousedNow != null && mousedNow.CanBeSelected ? mousedNow : null;
this.SelectElement(this.ActiveRoot, selectedNow);
if (mousedNow != null && mousedNow.CanBePressed) {
this.System.InvokeOnElementPressed(mousedNow);
- this.Input.TryConsumeMouseButtonPressed(MouseButton.Left);
+ this.Input.TryConsumePressed(MouseButton.Left);
}
- } else if (this.Input.IsMouseButtonPressedAvailable(MouseButton.Right)) {
+ } else if (this.Input.IsPressedAvailable(MouseButton.Right)) {
this.IsAutoNavMode = false;
if (mousedNow != null && mousedNow.CanBePressed) {
this.System.InvokeOnElementSecondaryPressed(mousedNow);
- this.Input.TryConsumeMouseButtonPressed(MouseButton.Right);
+ this.Input.TryConsumePressed(MouseButton.Right);
}
}
} else {
@@ -196,7 +196,7 @@ namespace MLEM.Ui {
}
this.KeyboardButtons.TryConsumePressed(this.Input, this.GamepadIndex);
}
- } else if (this.Input.IsKeyPressedAvailable(Keys.Tab)) {
+ } else if (this.Input.IsPressedAvailable(Keys.Tab)) {
this.IsAutoNavMode = true;
// tab or shift-tab to next or previous element
var backward = this.Input.IsModifierKeyDown(ModifierKey.Shift);
@@ -205,7 +205,7 @@ namespace MLEM.Ui {
next = this.SelectedElement.GetTabNextElement(backward, next);
if (next != this.SelectedElement) {
this.SelectElement(this.ActiveRoot, next);
- this.Input.TryConsumeKeyPressed(Keys.Tab);
+ this.Input.TryConsumePressed(Keys.Tab);
}
}
}
diff --git a/MLEM/Input/InputHandler.cs b/MLEM/Input/InputHandler.cs
index 0280403..6bd26ca 100644
--- a/MLEM/Input/InputHandler.cs
+++ b/MLEM/Input/InputHandler.cs
@@ -6,11 +6,12 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
+using static MLEM.Input.GenericInput;
namespace MLEM.Input {
///
/// An input handler is a more advanced wrapper around MonoGame's default input system.
- /// It includes keyboard, mouse, gamepad and touch states, as well as a new "pressed" state for keys and the ability for keyboard and gamepad repeat events.
+ /// It includes keyboard, mouse, gamepad and touch handling through the wrapper, as well as a new "pressed" state for inputs, the ability for keyboard and gamepad repeat events, and the ability to track down, up and press times for inputs.
///
public class InputHandler : GameComponent {
@@ -277,7 +278,7 @@ namespace MLEM.Input {
if (active) {
this.gamepads[i] = GamePad.GetState((PlayerIndex) i);
foreach (var button in InputHandler.AllButtons) {
- if (this.IsGamepadButtonDown(button, i))
+ if (this.IsDown(button, i))
this.AccumulateDown(button, i);
}
}
@@ -290,7 +291,7 @@ namespace MLEM.Input {
this.triggerGamepadButtonRepeat[i] = false;
if (this.HandleGamepadRepeats) {
this.heldGamepadButtons[i] = InputHandler.AllButtons
- .Where(b => this.IsGamepadButtonDown(b, i))
+ .Where(b => this.IsDown(b, i))
.OrderBy(b => this.GetDownTime(b, i))
.Cast().FirstOrDefault();
if (this.heldGamepadButtons[i].HasValue && this.TryGetDownTime(this.heldGamepadButtons[i].Value, out var heldTime, i)) {
@@ -398,22 +399,39 @@ namespace MLEM.Input {
return this.gamepads[index];
}
+ ///
+ /// Returns whether the given modifier key is down.
+ ///
+ /// The modifier key
+ /// If the modifier key is down
+ public bool IsModifierKeyDown(ModifierKey modifier) {
+ foreach (var key in modifier.GetKeys()) {
+ if (this.IsDown(key))
+ return true;
+ }
+ return false;
+ }
+
///
+ [Obsolete("This method is deprecated. Use the GenericInput version IsDown instead.")]
public bool IsKeyDown(Keys key) {
return this.KeyboardState.IsKeyDown(key);
}
///
+ [Obsolete("This method is deprecated. Use the GenericInput version IsUp instead.")]
public bool IsKeyUp(Keys key) {
return this.KeyboardState.IsKeyUp(key);
}
///
+ [Obsolete("This method is deprecated. Use the GenericInput version WasDown instead.")]
public bool WasKeyDown(Keys key) {
return this.LastKeyboardState.IsKeyDown(key);
}
///
+ [Obsolete("This method is deprecated. Use the GenericInput version WasUp instead.")]
public bool WasKeyUp(Keys key) {
return this.LastKeyboardState.IsKeyUp(key);
}
@@ -425,6 +443,7 @@ namespace MLEM.Input {
///
/// The key to query
/// If the key is pressed
+ [Obsolete("This method is deprecated. Use the GenericInput version IsPressed instead.")]
public bool IsKeyPressed(Keys key) {
// if the queried key is the held key and a repeat should be triggered, return true
if (this.HandleKeyboardRepeats && key == this.heldKey && this.triggerKeyRepeat)
@@ -440,6 +459,7 @@ namespace MLEM.Input {
///
/// The key to query
/// If the key is pressed
+ [Obsolete("This method is deprecated. Use the GenericInput version IsPressedIgnoreRepeats instead.")]
public bool IsKeyPressedIgnoreRepeats(Keys key) {
if (this.InvertPressBehavior)
return this.WasKeyDown(key) && this.IsKeyUp(key);
@@ -451,6 +471,7 @@ namespace MLEM.Input {
///
/// The key to query.
/// If the key is pressed and the press is not consumed yet.
+ [Obsolete("This method is deprecated. Use the GenericInput version IsPressedAvailable instead.")]
public bool IsKeyPressedAvailable(Keys key) {
return this.IsKeyPressed(key) && !this.IsPressConsumed(key);
}
@@ -463,6 +484,7 @@ namespace MLEM.Input {
///
/// The key to query.
/// If the key is pressed and the press is not consumed yet.
+ [Obsolete("This method is deprecated. Use the GenericInput version TryConsumePressed instead.")]
public bool TryConsumeKeyPressed(Keys key) {
if (this.IsKeyPressedAvailable(key)) {
this.consumedPresses.Add((key, -1));
@@ -471,24 +493,12 @@ namespace MLEM.Input {
return false;
}
- ///
- /// Returns whether the given modifier key is down.
- ///
- /// The modifier key
- /// If the modifier key is down
- public bool IsModifierKeyDown(ModifierKey modifier) {
- foreach (var key in modifier.GetKeys()) {
- if (this.IsKeyDown(key))
- return true;
- }
- return false;
- }
-
///
/// Returns whether the given mouse button is currently down.
///
/// The button to query
/// Whether or not the queried button is down
+ [Obsolete("This method is deprecated. Use the GenericInput version IsDown instead.")]
public bool IsMouseButtonDown(MouseButton button) {
return this.MouseState.GetState(button) == ButtonState.Pressed;
}
@@ -498,6 +508,7 @@ namespace MLEM.Input {
///
/// The button to query
/// Whether or not the queried button is up
+ [Obsolete("This method is deprecated. Use the GenericInput version IsUp instead.")]
public bool IsMouseButtonUp(MouseButton button) {
return this.MouseState.GetState(button) == ButtonState.Released;
}
@@ -507,6 +518,7 @@ namespace MLEM.Input {
///
/// The button to query
/// Whether or not the queried button was down
+ [Obsolete("This method is deprecated. Use the GenericInput version WasDown instead.")]
public bool WasMouseButtonDown(MouseButton button) {
return this.LastMouseState.GetState(button) == ButtonState.Pressed;
}
@@ -516,6 +528,7 @@ namespace MLEM.Input {
///
/// The button to query
/// Whether or not the queried button was up
+ [Obsolete("This method is deprecated. Use the GenericInput version WasUp instead.")]
public bool WasMouseButtonUp(MouseButton button) {
return this.LastMouseState.GetState(button) == ButtonState.Released;
}
@@ -526,6 +539,7 @@ namespace MLEM.Input {
///
/// The button to query
/// Whether the button is pressed
+ [Obsolete("This method is deprecated. Use the GenericInput version IsPressed instead.")]
public bool IsMouseButtonPressed(MouseButton button) {
if (this.InvertPressBehavior)
return this.WasMouseButtonDown(button) && this.IsMouseButtonUp(button);
@@ -537,6 +551,7 @@ namespace MLEM.Input {
///
/// The button to query.
/// If the button is pressed and the press is not consumed yet.
+ [Obsolete("This method is deprecated. Use the GenericInput version IsPressedAvailable instead.")]
public bool IsMouseButtonPressedAvailable(MouseButton button) {
return this.IsMouseButtonPressed(button) && !this.IsPressConsumed(button);
}
@@ -548,6 +563,7 @@ namespace MLEM.Input {
///
/// The button to query.
/// If the button is pressed and the press is not consumed yet.
+ [Obsolete("This method is deprecated. Use the GenericInput version TryConsumePressed instead.")]
public bool TryConsumeMouseButtonPressed(MouseButton button) {
if (this.IsMouseButtonPressedAvailable(button)) {
this.consumedPresses.Add((button, -1));
@@ -557,6 +573,7 @@ namespace MLEM.Input {
}
///
+ [Obsolete("This method is deprecated. Use the GenericInput version IsDown instead.")]
public bool IsGamepadButtonDown(Buttons button, int index = -1) {
if (index < 0) {
for (var i = 0; i < this.ConnectedGamepads; i++) {
@@ -569,6 +586,7 @@ namespace MLEM.Input {
}
///
+ [Obsolete("This method is deprecated. Use the GenericInput version IsUp instead.")]
public bool IsGamepadButtonUp(Buttons button, int index = -1) {
if (index < 0) {
for (var i = 0; i < this.ConnectedGamepads; i++) {
@@ -581,6 +599,7 @@ namespace MLEM.Input {
}
///
+ [Obsolete("This method is deprecated. Use the GenericInput version WasDown instead.")]
public bool WasGamepadButtonDown(Buttons button, int index = -1) {
if (index < 0) {
for (var i = 0; i < this.ConnectedGamepads; i++) {
@@ -593,6 +612,7 @@ namespace MLEM.Input {
}
///
+ [Obsolete("This method is deprecated. Use the GenericInput version WasUp instead.")]
public bool WasGamepadButtonUp(Buttons button, int index = -1) {
if (index < 0) {
for (var i = 0; i < this.ConnectedGamepads; i++) {
@@ -612,6 +632,7 @@ namespace MLEM.Input {
/// The button to query
/// The zero-based index of the gamepad, or -1 for any gamepad
/// Whether the given button is pressed
+ [Obsolete("This method is deprecated. Use the GenericInput version IsPressed instead.")]
public bool IsGamepadButtonPressed(Buttons button, int index = -1) {
if (this.HandleGamepadRepeats) {
if (index < 0) {
@@ -635,6 +656,7 @@ namespace MLEM.Input {
/// The button to query
/// The zero-based index of the gamepad, or -1 for any gamepad
/// Whether the given button is pressed
+ [Obsolete("This method is deprecated. Use the GenericInput version IsPressedIgnoreRepeats instead.")]
public bool IsGamepadButtonPressedIgnoreRepeats(Buttons button, int index = -1) {
if (this.InvertPressBehavior)
return this.WasGamepadButtonDown(button, index) && this.IsGamepadButtonUp(button, index);
@@ -647,6 +669,7 @@ namespace MLEM.Input {
/// The button to query.
/// The zero-based index of the gamepad, or -1 for any gamepad.
/// Whether the given button is pressed and the press is not consumed yet.
+ [Obsolete("This method is deprecated. Use the GenericInput version IsPressedAvailable instead.")]
public bool IsGamepadButtonPressedAvailable(Buttons button, int index = -1) {
return this.IsGamepadButtonPressed(button) && !this.IsPressConsumed(button, index) && (index < 0 || !this.IsPressConsumed(button));
}
@@ -660,6 +683,7 @@ namespace MLEM.Input {
/// The button to query.
/// The zero-based index of the gamepad, or -1 for any gamepad.
/// Whether the given button is pressed and the press is not consumed yet.
+ [Obsolete("This method is deprecated. Use the GenericInput version TryConsumePressed instead.")]
public bool TryConsumeGamepadButtonPressed(Buttons button, int index = -1) {
if (this.IsGamepadButtonPressedAvailable(button, index)) {
this.consumedPresses.Add((button, index));
@@ -722,15 +746,21 @@ namespace MLEM.Input {
/// The control whose down state to query
/// The index of the gamepad to query (if applicable), or -1 for any gamepad
/// Whether the given control is down
- /// If the passed control isn't of a supported type
public bool IsDown(GenericInput control, int index = -1) {
switch (control.Type) {
- case GenericInput.InputType.Keyboard:
- return this.IsKeyDown(control);
- case GenericInput.InputType.Gamepad:
- return this.IsGamepadButtonDown(control, index);
- case GenericInput.InputType.Mouse:
- return this.IsMouseButtonDown(control);
+ case InputType.Keyboard:
+ return this.KeyboardState.IsKeyDown(control);
+ case InputType.Gamepad:
+ if (index < 0) {
+ for (var i = 0; i < this.ConnectedGamepads; i++) {
+ if (this.GetGamepadState(i).GetAnalogValue(control) > this.GamepadButtonDeadzone)
+ return true;
+ }
+ return false;
+ }
+ return this.GetGamepadState(index).GetAnalogValue(control) > this.GamepadButtonDeadzone;
+ case InputType.Mouse:
+ return this.MouseState.GetState(control) == ButtonState.Pressed;
default:
return false;
}
@@ -743,15 +773,21 @@ namespace MLEM.Input {
/// The control whose up state to query
/// The index of the gamepad to query (if applicable), or -1 for any gamepad
/// Whether the given control is up.
- /// If the passed control isn't of a supported type
public bool IsUp(GenericInput control, int index = -1) {
switch (control.Type) {
- case GenericInput.InputType.Keyboard:
- return this.IsKeyUp(control);
- case GenericInput.InputType.Gamepad:
- return this.IsGamepadButtonUp(control, index);
- case GenericInput.InputType.Mouse:
- return this.IsMouseButtonUp(control);
+ case InputType.Keyboard:
+ return this.KeyboardState.IsKeyUp(control);
+ case InputType.Gamepad:
+ if (index < 0) {
+ for (var i = 0; i < this.ConnectedGamepads; i++) {
+ if (this.GetGamepadState(i).GetAnalogValue(control) <= this.GamepadButtonDeadzone)
+ return true;
+ }
+ return false;
+ }
+ return this.GetGamepadState(index).GetAnalogValue(control) <= this.GamepadButtonDeadzone;
+ case InputType.Mouse:
+ return this.MouseState.GetState(control) == ButtonState.Released;
default:
return true;
}
@@ -764,15 +800,21 @@ namespace MLEM.Input {
/// The control whose down state to query
/// The index of the gamepad to query (if applicable), or -1 for any gamepad
/// Whether the given control was down
- /// If the passed control isn't of a supported type
public bool WasDown(GenericInput control, int index = -1) {
switch (control.Type) {
- case GenericInput.InputType.Keyboard:
- return this.WasKeyDown(control);
- case GenericInput.InputType.Gamepad:
- return this.WasGamepadButtonDown(control, index);
- case GenericInput.InputType.Mouse:
- return this.WasMouseButtonDown(control);
+ case InputType.Keyboard:
+ return this.LastKeyboardState.IsKeyDown(control);
+ case InputType.Gamepad:
+ if (index < 0) {
+ for (var i = 0; i < this.ConnectedGamepads; i++) {
+ if (this.GetLastGamepadState(i).GetAnalogValue(control) > this.GamepadButtonDeadzone)
+ return true;
+ }
+ return false;
+ }
+ return this.GetLastGamepadState(index).GetAnalogValue(control) > this.GamepadButtonDeadzone;
+ case InputType.Mouse:
+ return this.LastMouseState.GetState(control) == ButtonState.Pressed;
default:
return false;
}
@@ -785,15 +827,21 @@ namespace MLEM.Input {
/// The control whose up state to query
/// The index of the gamepad to query (if applicable), or -1 for any gamepad
/// Whether the given control was up.
- /// If the passed control isn't of a supported type
public bool WasUp(GenericInput control, int index = -1) {
switch (control.Type) {
- case GenericInput.InputType.Keyboard:
- return this.WasKeyUp(control);
- case GenericInput.InputType.Gamepad:
- return this.WasGamepadButtonUp(control, index);
- case GenericInput.InputType.Mouse:
- return this.WasMouseButtonUp(control);
+ case InputType.Keyboard:
+ return this.LastKeyboardState.IsKeyUp(control);
+ case InputType.Gamepad:
+ if (index < 0) {
+ for (var i = 0; i < this.ConnectedGamepads; i++) {
+ if (this.GetLastGamepadState(i).GetAnalogValue(control) <= this.GamepadButtonDeadzone)
+ return true;
+ }
+ return false;
+ }
+ return this.GetLastGamepadState(index).GetAnalogValue(control) <= this.GamepadButtonDeadzone;
+ case InputType.Mouse:
+ return this.LastMouseState.GetState(control) == ButtonState.Released;
default:
return true;
}
@@ -801,23 +849,47 @@ namespace MLEM.Input {
///
/// Returns if a given control of any kind is pressed.
- /// This is a helper function that can be passed a , or .
+ /// If or are true, this method will also return true to signify a key or gamepad button repeat.
+ /// An input is considered pressed if it was not down the last update call, but is down the current update call. If is true, this behavior is inverted.
///
/// The control whose pressed state to query
/// The index of the gamepad to query (if applicable), or -1 for any gamepad
/// Whether the given control is pressed.
- /// If the passed control isn't of a supported type
public bool IsPressed(GenericInput control, int index = -1) {
+ // handle repeat events for specific inputs, and delegate to default "ignore repeats" behavior otherwise
switch (control.Type) {
- case GenericInput.InputType.Keyboard:
- return this.IsKeyPressed(control);
- case GenericInput.InputType.Gamepad:
- return this.IsGamepadButtonPressed(control, index);
- case GenericInput.InputType.Mouse:
- return this.IsMouseButtonPressed(control);
- default:
- return false;
+ case InputType.Keyboard:
+ if (this.HandleKeyboardRepeats && (Keys) control == this.heldKey && this.triggerKeyRepeat)
+ return true;
+ break;
+ case InputType.Gamepad:
+ if (this.HandleGamepadRepeats) {
+ if (index < 0) {
+ for (var i = 0; i < this.ConnectedGamepads; i++) {
+ if (this.heldGamepadButtons[i] == (Buttons) control && this.triggerGamepadButtonRepeat[i])
+ return true;
+ }
+ } else if (this.heldGamepadButtons[index] == (Buttons) control && this.triggerGamepadButtonRepeat[index]) {
+ return true;
+ }
+ }
+ break;
}
+ return this.IsPressedIgnoreRepeats(control, index);
+ }
+
+ ///
+ /// An input is considered pressed if it was not down the last update call, but is down the current update call. If is true, this behavior is inverted.
+ /// This has the same behavior as , but ignores keyboard and gamepad repeat events.
+ /// If and are false, this method does the same as .
+ ///
+ /// The control whose pressed state to query
+ /// The index of the gamepad to query (if applicable), or -1 for any gamepad
+ /// Whether the given control is pressed, ignoring repeat events.
+ public bool IsPressedIgnoreRepeats(GenericInput control, int index = -1) {
+ if (this.InvertPressBehavior)
+ return this.WasDown(control, index) && this.IsUp(control, index);
+ return this.WasUp(control, index) && this.IsDown(control, index);
}
///
@@ -827,16 +899,7 @@ namespace MLEM.Input {
/// The index of the gamepad to query (if applicable), or -1 for any gamepad.
/// Whether the given control is pressed and the press is not consumed yet.
public bool IsPressedAvailable(GenericInput control, int index = -1) {
- switch (control.Type) {
- case GenericInput.InputType.Keyboard:
- return this.IsKeyPressedAvailable(control);
- case GenericInput.InputType.Gamepad:
- return this.IsGamepadButtonPressedAvailable(control, index);
- case GenericInput.InputType.Mouse:
- return this.IsMouseButtonPressedAvailable(control);
- default:
- return false;
- }
+ return this.IsPressed(control, index) && !this.IsPressConsumed(control, index);
}
///
@@ -847,16 +910,11 @@ namespace MLEM.Input {
/// The index of the gamepad to query (if applicable), or -1 for any gamepad.
/// Whether the given control is pressed and the press is not consumed yet.
public bool TryConsumePressed(GenericInput control, int index = -1) {
- switch (control.Type) {
- case GenericInput.InputType.Keyboard:
- return this.TryConsumeKeyPressed(control);
- case GenericInput.InputType.Gamepad:
- return this.TryConsumeGamepadButtonPressed(control, index);
- case GenericInput.InputType.Mouse:
- return this.TryConsumeMouseButtonPressed(control);
- default:
- return false;
+ if (this.IsPressedAvailable(control, index)) {
+ this.consumedPresses.Add((control, index));
+ return true;
}
+ return false;
}
///
diff --git a/MLEM/Input/TextInput.cs b/MLEM/Input/TextInput.cs
index 0b010d2..c2945f2 100644
--- a/MLEM/Input/TextInput.cs
+++ b/MLEM/Input/TextInput.cs
@@ -289,16 +289,16 @@ namespace MLEM.Input {
this.CaretPos--;
} else if (this.CaretPos < this.text.Length && input.TryConsumePressed(Keys.Right)) {
this.CaretPos++;
- } else if (this.Multiline && input.IsKeyPressedAvailable(Keys.Up) && this.MoveCaretToLine(this.CaretLine - 1)) {
+ } else if (this.Multiline && input.IsPressedAvailable(Keys.Up) && this.MoveCaretToLine(this.CaretLine - 1)) {
input.TryConsumePressed(Keys.Up);
- } else if (this.Multiline && input.IsKeyPressedAvailable(Keys.Down) && this.MoveCaretToLine(this.CaretLine + 1)) {
+ } else if (this.Multiline && input.IsPressedAvailable(Keys.Down) && this.MoveCaretToLine(this.CaretLine + 1)) {
input.TryConsumePressed(Keys.Down);
} else if (this.CaretPos != 0 && input.TryConsumePressed(Keys.Home)) {
this.CaretPos = 0;
} else if (this.CaretPos != this.text.Length && input.TryConsumePressed(Keys.End)) {
this.CaretPos = this.text.Length;
} else if (input.IsModifierKeyDown(ModifierKey.Control)) {
- if (input.IsKeyPressedAvailable(Keys.V)) {
+ if (input.IsPressedAvailable(Keys.V)) {
var clip = this.PasteFromClipboardFunction?.Invoke();
if (clip != null) {
this.InsertText(clip, true);
diff --git a/Sandbox/GameImpl.cs b/Sandbox/GameImpl.cs
index c746e4d..c3d254f 100644
--- a/Sandbox/GameImpl.cs
+++ b/Sandbox/GameImpl.cs
@@ -387,7 +387,7 @@ public class GameImpl : MlemGame {
protected override void DoUpdate(GameTime gameTime) {
base.DoUpdate(gameTime);
- if (this.InputHandler.IsKeyPressed(Keys.F11))
+ if (this.InputHandler.IsPressed(Keys.F11))
this.GraphicsDeviceManager.SetFullscreen(!this.GraphicsDeviceManager.IsFullScreen);
var delta = this.InputHandler.ScrollWheel - this.InputHandler.LastScrollWheel;