-
Notifications
You must be signed in to change notification settings - Fork 0
Keyboard
There are two 3D keyboards provided with this framework:
A full text keyboard and a numeric keyboard.
They are both saved as prefabs in the resource folder so that they can be loaded via code.
Both keyboard types consist of a Keyboard
script and several Key
scripts.
Furthermore there is a BluetoothKeyboard
script which handles user input on a bluetooth keyboard and applies this input the the 3D keyboard.
The Keyboard
script automatically finds all key objects which are children.
It also provides static Display(...)
methods in order to quickly instantiate and initialize the keyboard from code.
Define a callback-method and provide it to the display-method.
The callback method should take one string as an argument.
When the user inputs is finished, this string will contain the input result.
If the user cancels the input, the string argument will be set to
null
. This must be checked in the callback method.
The keyboard is defined as a Window
and is thus considered by the WindowManager
.
The keys can have several KeyTypes
: LETTER, ENTER, BACKSPACE, ACCEPT, CANCEL
which define their behavior when they are pressed.
-
KeyType.LETTER
: adds the provided string forletter
to the text of the keyboard. -
KeyType.ENTER
: adds a new line to the text of the keyboard -
KeyType.BACKSPACE
: removes the last char from the text of the keyboard. -
KeyType.ACCEPT
: callsAccept()
on theKeyboard
. This provides the user input to the defined callback-method. -
KeyType.CANCEL
: callsCancel()
on theKeyboard
. This provides a null-string to the defined callback-method.
Note that if if the key type is set to
Letter
, the key gameobject is automatically renamed to "Key < letter >" and the assigned text- mesh caption is also set to the provided letter. This action is performed in the editor and at runtime.
The keys are standard buttons which are augmented by a key component. This component communicates with the keyboard and maps the key's functionality to the behavior of the button.
For bluetooth support, the BluetoothKeyboard
is attached to the keyboard 3D object. At runtime, it creates a pseudo key of key type letter. If the user presses a button on the physical keyboard, this is registered by this script and the input is applied to the pseudo key as a letter. After that, the OnPressed
method of the pseudo key is invoked in order to apply the input to the 3D keyboard.
- Button Template: Description of the button template which is the basis for the implemented keys
- Buttons: Description of the different implemented buttons which are adapted to keys
- Localization Manager: Sets the keyboard's language