diff options
author | crupest <crupest@outlook.com> | 2023-10-18 22:55:18 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2023-10-18 22:55:18 +0800 |
commit | e8abfdb0c1d3e918bfaac2077cc7e5332c1cfaf9 (patch) | |
tree | 9f90a0ca3d49cb33ba9ad28568d5e400ceeffce7 /include/cru | |
parent | 0a67b1c862954d0d18d4fbf322c31ea0faf065d7 (diff) | |
download | cru-e8abfdb0c1d3e918bfaac2077cc7e5332c1cfaf9.tar.gz cru-e8abfdb0c1d3e918bfaac2077cc7e5332c1cfaf9.tar.bz2 cru-e8abfdb0c1d3e918bfaac2077cc7e5332c1cfaf9.zip |
Fix input method bugs on macos.
There are a lot of problems about input methods and we will definitely
spend more on this. And the bug made me awkward on today's interview
when showing the demo.
Diffstat (limited to 'include/cru')
-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 - |