magicleap / MagicLeapXRKeyboard

A keyboard that can be used in any project that supports Unity's XR Interaction Toolkit.
Other
8 stars 1 forks source link

Keyboard ignores custom content type keyboard type #3

Closed sern19 closed 5 months ago

sern19 commented 6 months ago

If we set input type content type to custom and then manually select the keyboard type to e.g. Number Pad, TMPInputFieldTextReceiver component still spawns full keyboard (letters).

Expected behaviour is to behave the same way as the content type set to integer number or PIN.

ababilinski commented 6 months ago

@sern19 Interesting! What version of the package are you using? Can you test out the example scene? It should have examples of using Decimal, Integer, and Pin.

sern19 commented 6 months ago

Sure, I'm using version 0.3.3, I've modified sample project and reproduced the issue: CustomInputField.zip

If we track code execution the reason is pretty clear, so let's assume we have an input field with a custom content type set up like this:

image

Which is basically the same as PIN content type (to simplify things). Keyboard type is set as Nubmer Pad.

Next to the Input field, TMPInputFieldTextReceiver behaviour is attached. Now we can track what happens.

  1. When input field is selected, EnableInput method is called: https://github.com/magicleap/MagicLeapXRKeyboard/blob/449a48080bab6614639082be8c8f11c755a0c8a0/Packages/MagicLeapXRKeyboard/Runtime/Scripts/Keyboard/TMPInputFieldTextReceiver.cs#L57-L67
  2. KeyboardManager.Instance.ShowKeyboard is called but only with input field content type (which is a problem for custom type): https://github.com/magicleap/MagicLeapXRKeyboard/blob/449a48080bab6614639082be8c8f11c755a0c8a0/Packages/MagicLeapXRKeyboard/Runtime/Scripts/Keyboard/KeyboardManager.cs#L74-L98
  3. Next, _keyboard.SetKeyboard is called and content type is saved: https://github.com/magicleap/MagicLeapXRKeyboard/blob/449a48080bab6614639082be8c8f11c755a0c8a0/Packages/MagicLeapXRKeyboard/Runtime/Scripts/Keyboard/Keyboard.cs#L160-L186
  4. Finally, keyboard layout is updated based on the content type, but since our type is custom, keyboard is always a full keyboard layout: https://github.com/magicleap/MagicLeapXRKeyboard/blob/449a48080bab6614639082be8c8f11c755a0c8a0/Packages/MagicLeapXRKeyboard/Runtime/Scripts/Keyboard/Keyboard.cs#L189-L233

A proper way to handle the custom content type would be to check input field keyboard type when updating keyboard layout here: https://github.com/magicleap/MagicLeapXRKeyboard/blob/449a48080bab6614639082be8c8f11c755a0c8a0/Packages/MagicLeapXRKeyboard/Runtime/Scripts/Keyboard/Keyboard.cs#L227-L230

sern19 commented 5 months ago

@ababilinski Any updates on this issue? Would this be considered as a bug and fixed later or is it by design and will not be handled?

ababilinski commented 5 months ago

@sern19 Did the new branch fix your issue?

sern19 commented 5 months ago

@ababilinski Sorry for late reply, I can confirm that #4 fixes this issue