Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental TextmeshPro and UnityUI input field helpers that work with HoloLens keyboard #7577

Merged
merged 37 commits into from Mar 25, 2020

Conversation

julenka
Copy link
Contributor

@julenka julenka commented Mar 23, 2020

This PR is a continuation of the PR from @Alexees #6036, thank you to alexees for the original fix.

Additional changes on top of @Alexees original PR:

  • Moves files related to the MixedRealityKeyboard to SDK/Experimental/MixedRealityKeyboard/
  • Move MixedRealityKeyboardPreview classes into Experimental/MixedRealityKeyboardPreview folder
  • Add text input field to the hand interaction examples scene

Original PR from @Alexees:

Overview

The class MixedRealityKeyboard is a MonoBehaviour that shows how to Open, Close and use the system native keyboards on UWP platforms.

The programmer still has the responsibility to link it with whatever she/he needs the input for. This means she/he needs to write additional MonoBehaviour scripts to link the with for example InputFields, which activate on click.

I wanted to make this easier in that InputFields and TMP_InputFields are handled directly by just one additional script attached to them.

Fixes: #3970 by providing a workaround -- to get the keyboard to show up, attach the input field helper component to the gameobject containing the input field.

Changes

This set of scripts provides the following:

  • A script, once attached to Unity InputFields, automatically manages the native keyboard and updates the InputFields text
  • Same for the TMP_InputField
  • Base classes to derive from if you want to use the keyboard for something other than InputFields

I first went for overriding the InputFields, but first, they are far too complicated to just do that and second, The existing implementation of MixedRealityKeyboard.cs already completely ignores InputField interactions and second there might be more uses for the keyboard than just InputFields.

alexees and others added 21 commits September 23, 2019 15:02
…ext; added starting the keyboard with the text of inputfields; added class descriptions
…RealityToolkit-Unity into mrtk_experimental_inputFieldKeyboadHelper

# Conflicts:
#	Assets/MixedRealityToolkit.Examples/Demos/HandTracking/Script/SystemKeyboardExample.cs
#	Assets/MixedRealityToolkit.SDK/Experimental/MixedRelityKeyboard/MixedRealityKeyboardBase.cs
@julenka
Copy link
Contributor Author

julenka commented Mar 24, 2020

Found a bug: after typing text and closing keyboard, then re-opening the keyboard, text will be set to empty string and you see "enter text..." prompt again.

Fixed

@julenka
Copy link
Contributor Author

julenka commented Mar 24, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@julenka
Copy link
Contributor Author

julenka commented Mar 24, 2020

Found another bug:
In the UI.InputField box if you enter text, close the keyboard, enter text again, close the keyboard, then try to enter text, the input box does not reflect the keys pressed on the keyboard.

After my latest fix I can't reproduce the issue, seems fixed, or not 100% repro. Since this is experimental, bugs that occur infrequently (< 25% of cases) are acceptable. I noticed in one of four times I brought up keyboard, that I typed "One" and the letters ended up "noo", but was not able to reproduce after several more attempts.

Comment on lines 1 to 4
# Mixed Reality and HoloLens Keyboard helpers

MRTK provides several experimental helper components to assist with launching and reading text from the [System Keyboard](../../../../../Documentation/README_SystemKeyboard.md).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be helpful to note that the keyboard does not work in editor or while remoting.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@julenka julenka self-assigned this Mar 24, 2020
@julenka
Copy link
Contributor Author

julenka commented Mar 25, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Copy link
Contributor

@CDiaz-MS CDiaz-MS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the new changes and it looks good to me.

@julenka
Copy link
Contributor Author

julenka commented Mar 25, 2020

For the future: @CDiaz-MS noticed that Unity UI will sometimes select all of the text when the text input field is selected. Since this is the default Unity behavior, we decided not to change it. If we want to force Unity UI to always move the caret to the end, solutions are presented here: https://stackoverflow.com/questions/41484725/how-to-disable-selectall-text-of-ui-inputfield-when-it-gets-focus

@julenka
Copy link
Contributor Author

julenka commented Mar 25, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@julenka julenka merged commit 824a100 into microsoft:mrtk_development Mar 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unity UI text edit field should make virtual keyboard appear
4 participants