IME Manager¶
Introduction¶
The IME Manager provides an interface for managing the system keyboard.
Prerequisite¶
Import the VIVE Wave XR Plugin - Essence package and add include the Wave.Essence namespace to start using IME Manager.
How to use¶
Initialization¶
Obtain an IMEManager instance:
private IMEManager imeManagerInstance = null;
void Start() //Monobehaviour Start
{
imeManagerInstance = IMEManager.instance;
}
Initialize an IMEParameter object that holds the configurations of the keyboard:
private IMEManager.IMEParameter currentIMEParameter = null;
int MODE_FLAG_FIX_MOTION = 0x02;
public void InitParameter()
{
int id = 0;
int type = MODE_FLAG_FIX_MOTION;
int mode = 2;
string exist = "";
int cursor = 0;
int selectStart = 0;
int selectEnd = 0;
double[] pos = new double[] { 0, 0, -1 };
double[] rot = new double[] { 1.0, 0.0, 0.0, 0.0 };
int width = 800;
int height = 800;
int shadow = 100;
string locale = "";
string title = "";
int extraInt = 0;
string extraString = "";
int buttonId = CONTROLLER_BUTTON_DEFAULT;
currentIMEParameter = new IMEManager.IMEParameter(id, type, mode, exist, cursor, selectStart, selectEnd, pos,
rot, width, height, shadow, locale, title, extraInt, extraString, buttonId);
}
Parameters
- id : ID of the keyboard, use different ID for different keyboards.
- type : Position type of the keyboard.
- mode : Should be the same value as type.
- exist : The string that will be present in the keyboard editor panel.
- cursor : Position of the blinking caret in the editor panel.
- selectStart : Starting position of the text selection.
- selectEnd : Ending position of the text selection.
- pos : Position of the keyboard.
- rot : Rotation of the keyboard.
- width : Width of the keyboard.
- height : Height of the keyboard.
- shadow : This value determines whether or not a grey shadow will be displayed as the background when the keyboard is active. Set value to 100 to display the shadow, 0 if not.
- locale : Locale of the keyboard. Only “en_US” is supported currently. To show a numeric keypad, set this parameter to “numeric”.
- title : String to be displayed above the editor panel of the keyboard.
- buttonId : The WVR_InputId of the buttons to used for interacting with the keyboard(i.e. Pressing the keys).
Note
The parameters above should be treated as preferred configurations.
Whether they will be applied or not depends on the IME implementation on the target device. For example, the pos, rot, width, height and shadow parameters may be overridden by the target device over UX design concerns.
Setting up an input/click callback¶
Set up a callback to specify the action to be carried out when input is completed/a key is clicked. Here are some examples:
public void inputDoneCallback(IMEManager.InputResult results) //Pass this callback as a parameter when calling showKeyboard()
{
//Action to do when input is completed
}
public void inputClickCallback(IMEManager.InputResult results) //Pass this callback as a parameter when calling showKeyboard()
{
//Action to do when input is completed
}
Activating the keyboard¶
Call the following function to activate the keyboard:
public void showKeyboard(IMEParameter parameter, bool isEnableEditorPanel, inputCompleteCallback cb, inputClickedCallback clickedCallback)
Parameters
- parameter : An IMEParameter object that holds the configurations of the keyboard.
- isEnableEditorPanel : Specify whether an editor panel will be displayed above the keyboard. Set this value to true to display the display panel.
- inputCompleteCallback : A callback function that accepts an IMEManager.InputResult object as parameter. Will be called when input is completed.
- inputClickedCallback : A callback function that accepts an IMEManager.InputResult object as parameter. Will be called when a key on the keyboard is clicked.
Here are some examples:
public void ShowKeyboardEnablePanel()
{
imeManagerInstance.showKeyboard(currentIMEParameter, true, inputDoneCallback, inputClickCallback);
}
public void ShowKeyboardDisablePanel()
{
imeManagerInstance.showKeyboard(currentIMEParameter, false, inputDoneCallback, inputClickCallback);
}
Deactivating the keyboard¶
Call the following function to manually deactivate the keyboard:
public void hideKeyboard()
Resources¶
The IMEManager and IMEManagerWrapper scripts are included in the VIVE Wave XR Plugin - Essence package.
Sample Scripts and Scenes:
- Import the VIVE Wave XR Plugin - Essence package sample from the Unity Package Manager.
- The IME Manager related samples can be found in Assets/Samples/Wave/IMEMgr_Test.
Common Issues and Solutions¶
- Application crashes when trying to update an Unity UI Input Field/Text Component in the input complete/click callback.
- Try caching the input result obtained through the callback and update the Unity UI Input Field/Text Component in Update() or other Monobehaviour lifecycle events instead.
- Application freezes after calling hideKeyboard().
- Try calling hideKeyboard() in the input complete/click callback.