diff options
Diffstat (limited to 'include/cru/platform/gui/InputMethod.h')
-rw-r--r-- | include/cru/platform/gui/InputMethod.h | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/include/cru/platform/gui/InputMethod.h b/include/cru/platform/gui/InputMethod.h index 45e11c06..90d6b15a 100644 --- a/include/cru/platform/gui/InputMethod.h +++ b/include/cru/platform/gui/InputMethod.h @@ -21,6 +21,24 @@ struct CompositionText { TextRange selection; }; +/** + * \remarks I think it's time to standatdize this. The most important thing is + * the events. + * + * The events hould be triggered in this way. + * 1. Any time the IME begins to work, CompositionStartEvent is fired. Only + * once. Not triggerred again until CompositionEndEvent is fired. + * 2. Any time composition state changed, maybe user typed more characters, or + * user commit part of composition, CompositionEvent is fired. + * 3. TextEvent is fired when user commit part or whole of the composition. And + * you can use the args to get what characters are committed. So it is where you + * get the real text user want to give you. + * 4. Whenever a commit happens, TextEvent first, followed by CompositionEvent. + * Each for once. So use the TextEvent to get real input and use + * CompositionEvent to update UI. + * 5. When composition stops, a final CompositionEndEvent is fired. Also only + * once. + */ struct IInputMethodContext : virtual IPlatformResource { // Return true if you should draw composition text manually. Return false if // system will take care of that for you. @@ -36,20 +54,13 @@ struct IInputMethodContext : virtual IPlatformResource { virtual CompositionText GetCompositionText() = 0; - // Set the candidate window lefttop. Relative to window lefttop. Use this + // Set the candidate window left-top. Relative to window left-top. Use this // method to prepare typing. virtual void SetCandidateWindowPosition(const Point& point) = 0; - // Triggered when user starts composition. virtual IEvent<std::nullptr_t>* CompositionStartEvent() = 0; - - // Triggered when user stops composition. virtual IEvent<std::nullptr_t>* CompositionEndEvent() = 0; - - // Triggered every time composition text changes. virtual IEvent<std::nullptr_t>* CompositionEvent() = 0; - virtual IEvent<StringView>* TextEvent() = 0; }; } // namespace cru::platform::gui - |