@@ -33,22 +33,16 @@ public static class TextInputEXT
3333 /// </summary>
3434 public static event Action < string , int , int > TextEditing ;
3535
36+ public static event Action < string [ ] , int , bool > TextEditingCandidates ;
37+
3638 #endregion
3739
3840 #region Public Properties
3941
40- static IntPtr windowHandle ;
4142 public static IntPtr WindowHandle
4243 {
43- get => windowHandle ;
44- set
45- {
46- #if WINDOWS7_0_OR_GREATER && ! WINDOWS10_0_17763_0_OR_GREATER
47- if ( value != IntPtr . Zero && windowHandle != value )
48- AdvancedImeInit ( value ) ;
49- #endif
50- windowHandle = value ;
51- }
44+ get ;
45+ set ;
5246 }
5347
5448 #endregion
@@ -65,11 +59,7 @@ public static IntPtr WindowHandle
6559 /// <returns>True if text input state is active</returns>
6660 public static bool IsTextInputActive ( )
6761 {
68- #if WINDOWS7_0_OR_GREATER && ! WINDOWS10_0_17763_0_OR_GREATER
69- return ImeSharp . InputMethod . Enabled ;
70- #else
7162 return FNAPlatform . IsTextInputActive ( WindowHandle ) ;
72- #endif
7363 }
7464
7565 public static bool IsScreenKeyboardShown ( )
@@ -84,22 +74,12 @@ public static bool IsScreenKeyboardShown(IntPtr window)
8474
8575 public static void StartTextInput ( )
8676 {
87- #if WINDOWS7_0_OR_GREATER && ! WINDOWS10_0_17763_0_OR_GREATER
88- // Need to ensure SDL2 text input is stopped
89- FNAPlatform . StopTextInput ( WindowHandle ) ;
90- ImeSharp . InputMethod . Enabled = true ;
91- #else
9277 FNAPlatform . StartTextInput ( WindowHandle ) ;
93- #endif
9478 }
9579
9680 public static void StopTextInput ( )
9781 {
98- #if WINDOWS7_0_OR_GREATER && ! WINDOWS10_0_17763_0_OR_GREATER
99- ImeSharp . InputMethod . Enabled = false ;
100- #else
10182 FNAPlatform . StopTextInput ( WindowHandle ) ;
102- #endif
10383 }
10484
10585 /// <summary>
@@ -109,12 +89,7 @@ public static void StopTextInput()
10989 /// <param name="rectangle">Text input location relative to GameWindow.ClientBounds</param>
11090 public static void SetInputRectangle ( Rectangle rectangle )
11191 {
112- #if WINDOWS7_0_OR_GREATER && ! WINDOWS10_0_17763_0_OR_GREATER
113- if ( ImeSharp . InputMethod . Enabled )
114- ImeSharp . InputMethod . SetTextInputRect ( rectangle . X , rectangle . Y , rectangle . Width , rectangle . Height ) ;
115- #else
11692 FNAPlatform . SetTextInputRectangle ( WindowHandle , rectangle ) ;
117- #endif
11893 }
11994
12095 #endregion
@@ -137,51 +112,14 @@ internal static void OnTextEditing(string text, int start, int length)
137112 }
138113 }
139114
140- #endregion
141-
142- #if WINDOWS7_0_OR_GREATER && ! WINDOWS10_0_17763_0_OR_GREATER
143- internal static void AdvancedImeInit ( IntPtr sdlWindowHandle )
115+ internal static void OnTextEditingCandidates ( string [ ] candidates , int selectedCandidate , bool horizontal )
144116 {
145- var windowProps = SDL3 . SDL . SDL_GetWindowProperties ( sdlWindowHandle ) ;
146- nint hwnd = SDL3 . SDL . SDL_GetPointerProperty ( windowProps , SDL3 . SDL . SDL_PROP_WINDOW_WIN32_HWND_POINTER , IntPtr . Zero ) ;
147-
148- // Only initialize InputMethod once
149- if ( ImeSharp . InputMethod . WindowHandle == IntPtr . Zero )
150- ImeSharp . InputMethod . Initialize ( hwnd , ShowOSImeWindow ) ;
151-
152- ImeSharp . InputMethod . TextInputCallback = OnTextInput ;
153- ImeSharp . InputMethod . TextCompositionCallback = ( compositionText , cursorPosition ) => {
154- OnTextEditing ( compositionText , cursorPosition , 0 ) ;
155- } ;
117+ if ( TextEditingCandidates != null )
118+ {
119+ TextEditingCandidates ( candidates , selectedCandidate , horizontal ) ;
120+ }
156121 }
157122
158- /// <summary>
159- /// Show the IME Candidate window rendered by the OS. Defaults to true.<br/>
160- /// Set to <c>false</c> if you want to render the IME candidate list yourself.<br/>
161- /// Note there's no way to toggle this option while game running! Please set this value main function or static initializer.<br/>
162- /// **This is a Windows only API.**
163- /// </summary>
164- public static bool ShowOSImeWindow ;
165-
166- /// <summary>
167- /// The candidate text list for the current composition.<br/>
168- /// If the composition string does not generate candidates, the candidate page size is zero.
169- /// This array is fixed length of 16.<br/>
170- /// **This property is only supported on Windows.**
171- /// </summary>
172- public static ImeSharp . IMEString [ ] CandidateList => ImeSharp . InputMethod . CandidateList ;
173-
174- /// <summary>
175- /// IME Candidate page size.<br/>
176- /// **This property is only supported on Windows.**
177- /// </summary>
178- public static int CandidatePageSize => ImeSharp . InputMethod . CandidatePageSize ;
179-
180- /// <summary>
181- /// The selected IME candidate index.<br/>
182- /// **This property is only supported on Windows.**
183- /// </summary>
184- public static int CandidateSelection => ImeSharp . InputMethod . CandidateSelection ;
185- #endif
123+ #endregion
186124 }
187- }
125+ }
0 commit comments