|
Size: 2392
Comment:
|
Size: 2855
Comment: null
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 22: | Line 22: |
| 1. The user activates an input method. This is typically done via a hotkey or by selecting an input method in a GUI. | 1. The user activates an input method ([[#IME|IME]]). This is typically done via a hotkey or by selecting an input method in a GUI. |
| Line 25: | Line 25: |
| 1. The user determines the composition is satisfactory and commits it (usually with the enter key). The user may instead choose to open the [[#CandidateList|Candidate List]] and select a [[#Candidate|Candidate]]. 1. The [[#IME|IME]] passes on the text that has been generated. |
1. The user determines the composition is satisfactory and commits it (usually with the enter key). Alternatively, the user may choose to open the [[#CandidateList|Candidate List]] and select a [[#Candidate|Candidate]]. 1. The [[#IME|IME]] passes on the committed text to the application. |
| Line 30: | Line 30: |
| Whenever the [[#Composition|Composition]] is changed, the application can retrieve it. | There are multiple input method styles which you can read about [[http://www.mozilla.org/projects/intl/input-method-spec.html|here]]. SDL supports "on-the-spot" mode. This has an important implication: the application is responsible for drawing the composition. |
| Line 43: | Line 43: |
One important thing to notice is that the application can enable and disable text input arbitrarily with [[SDL_StartTextInput]] and [[SDL_StopTextInput]]. [[SDL_SetTextInputRect]] controls where the [[#CandidateList|Candidate List]] will open, if supported. |
Text Input
Contents
Why?
Why does SDL need a text input API?
When I press a key on my keyboard, my program receives a character event, right?
Well, it's not always that simple. Sometimes it can take multiple key presses to produce a character. Sometimes a single key press can produce multiple characters.
Text input is not as simple as it seems, particularly when you consider International users (and you should). It's not hard to figure out why that is when you look at languages like Chinese, Japanese, and Korean. These languages, collectively referred to as the CJK, have thousands of symbols.
It would not be feasible to have a keyboard with over ten-thousand keys, would it? The solution to this is a software input method.
Terms
IME - Input Method Editor. A software input method. This is typically a program that intercepts key presses and interprets them before (eventually) passing them onto the application.
Composition - The text a user is currently inputting. This text is not yet finalized (committed) and the IME may modify it.
Candidate - An optional alternative text for the composition, gathered by the IME in the Candidate List.
Candidate List - A list of Candidates, used when there is any ambiguity.
Basic Workflow
The user activates an input method (IME). This is typically done via a hotkey or by selecting an input method in a GUI.
The user begins to type in their selected language, starting a Composition.
The IME intercepts the key press events and interprets them.
The user determines the composition is satisfactory and commits it (usually with the enter key). Alternatively, the user may choose to open the Candidate List and select a Candidate.
The IME passes on the committed text to the application.
While this provides a good overview, it may not be accurate for all platforms.
There are multiple input method styles which you can read about here. SDL supports "on-the-spot" mode. This has an important implication: the application is responsible for drawing the composition.
SDL
So how does SDL handle text input?
Functions
Events
One important thing to notice is that the application can enable and disable text input arbitrarily with SDL_StartTextInput and SDL_StopTextInput. SDL_SetTextInputRect controls where the Candidate List will open, if supported.
