Gameface has full support for Input Method Editor (IME) which enables an application to handle Asian language input.

With the IME the user can input text in East Asian languages such as Chinese, Korean and Japanese. It translates multiple keystrokes to characters, from the respective languages, that otherwise can’t be represented individually on keyboards.

Although IME is an OS feature, any application (and middleware like Gameface) has to provide some methods in order to make the user interaction work correctly.

A great explanation of IME for Windows and how it could work in a generic game is available here. Other OSes differ somewhat but the principles remain the same. Cohtml’s IME API is OS agnostic and the user should just bridge the OS-specific logic to the SDK.

Detailed explanation

The IME-related functionality is exposed through some cohtml::View methods and cohtml::IViewListener events:

The View contains 3 methods that deal with the current IME composition directly:

  • cohtml::View::IMESetComposition is used to show the client the state of the current composition - it will be underlined to give a visual clue that the composition is still in progress.
  • cohtml::View::IMEConfirmComposition tells the View that the passed composition must be accepted - it will appear in the text box as final.
  • cohtml::View::IMECancelComposition tells the View to discard the current composition.

Cohtml also provides some events called on the cohtml::IViewListener that allow for the correct composition and positioning of the IME windows:

  • cohtml::IViewListener::OnTextInputTypeChanged is called whenever the input focus in the view changes. The application should tell the OS that it accepts IME input when the user has focused a text field but it should not do it when for example the user has clicked on a picture or is not writing text anywhere.

  • cohtml::IViewListener::OnCaretRectChanged informs where the caret is currently in the View.