Skip to content

Commit

Permalink
Disable keyboard navigation while typing (#396)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholas-karr authored May 30, 2023
1 parent e0b82dd commit d4451d6
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions Assets/Script/Input/InputStrategy.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using PlasticBand.Haptics;
using TMPro;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.LowLevel;
Expand Down Expand Up @@ -186,9 +189,17 @@ private void OnInputEvent(InputEventPtr eventPtr) {
// Only take state events
if (!eventPtr.IsA<StateEvent>() && !eventPtr.IsA<DeltaStateEvent>()) {
return;
}

// Update mapping states
}

// Ignore navigation events from the keyboard while a text box is selected
// We detect whether a text box is selected by seeing if a focused input field is a component of the currently selected object
if (eventPtr.deviceId == Keyboard.current.deviceId &&
(EventSystem.current.currentSelectedGameObject?.GetComponents<TMP_InputField>().Any(i => i.isFocused) ?? false)) {

return;
}

// Update mapping states
foreach (var mapping in inputMappings.Values) {
mapping.UpdateState(eventPtr);
}
Expand Down

0 comments on commit d4451d6

Please sign in to comment.