File tree Expand file tree Collapse file tree 4 files changed +24
-18
lines changed Expand file tree Collapse file tree 4 files changed +24
-18
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,10 @@ pub enum InputMethod<T = String> {
1111    /// No input method is allowed. 
1212Disabled , 
1313    /// Input methods are allowed, but not open yet. 
14- Allowed , 
14+ Allowed  { 
15+         /// The position at which the input method dialog should be placed. 
16+ position :  Point , 
17+     } , 
1518    /// Input method is open. 
1619Open  { 
1720        /// The position at which the input method dialog should be placed. 
@@ -117,7 +120,7 @@ impl InputMethod {
117120        match  ( & self ,  other)  { 
118121            ( InputMethod :: Open  {  .. } ,  _) 
119122            | ( 
120-                 InputMethod :: Allowed , 
123+                 InputMethod :: Allowed   {  ..  } , 
121124                InputMethod :: None  | InputMethod :: Disabled , 
122125            ) 
123126            | ( InputMethod :: Disabled ,  InputMethod :: None )  => { } 
@@ -142,7 +145,9 @@ impl<T> InputMethod<T> {
142145        match  self  { 
143146            Self :: None  => InputMethod :: None , 
144147            Self :: Disabled  => InputMethod :: Disabled , 
145-             Self :: Allowed  => InputMethod :: Allowed , 
148+             Self :: Allowed  {  position }  => InputMethod :: Allowed  { 
149+                 position :  * position, 
150+             } , 
146151            Self :: Open  { 
147152                position, 
148153                purpose, 
Original file line number Diff line number Diff line change @@ -339,10 +339,6 @@ where
339339            return  InputMethod :: Disabled ; 
340340        } ; 
341341
342-         let  Some ( preedit)  = & state. preedit  else  { 
343-             return  InputMethod :: Allowed ; 
344-         } ; 
345- 
346342        let  bounds = layout. bounds ( ) ; 
347343        let  internal = self . content . 0 . borrow_mut ( ) ; 
348344
@@ -363,6 +359,10 @@ where
363359        let  position =
364360            cursor + translation + Vector :: new ( 0.0 ,  f32:: from ( line_height) ) ; 
365361
362+         let  Some ( preedit)  = & state. preedit  else  { 
363+             return  InputMethod :: Allowed  {  position } ; 
364+         } ; 
365+ 
366366        InputMethod :: Open  { 
367367            position, 
368368            purpose :  input_method:: Purpose :: Normal , 
Original file line number Diff line number Diff line change @@ -406,10 +406,6 @@ where
406406            return  InputMethod :: Disabled ; 
407407        } ; 
408408
409-         let  Some ( preedit)  = & state. is_ime_open  else  { 
410-             return  InputMethod :: Allowed ; 
411-         } ; 
412- 
413409        let  secure_value = self . is_secure . then ( || value. secure ( ) ) ; 
414410        let  value = secure_value. as_ref ( ) . unwrap_or ( value) ; 
415411
@@ -432,9 +428,14 @@ where
432428
433429        let  x = ( text_bounds. x  + cursor_x) . floor ( )  - scroll_offset
434430            + alignment_offset; 
431+         let  position = Point :: new ( x,  text_bounds. y  + text_bounds. height ) ; 
432+ 
433+         let  Some ( preedit)  = & state. is_ime_open  else  { 
434+             return  InputMethod :: Allowed  {  position } ; 
435+         } ; 
435436
436437        InputMethod :: Open  { 
437-             position :   Point :: new ( x ,  text_bounds . y  + text_bounds . height ) , 
438+             position, 
438439            purpose :  if  self . is_secure  { 
439440                input_method:: Purpose :: Secure 
440441            }  else  { 
Original file line number Diff line number Diff line change @@ -210,8 +210,13 @@ where
210210            InputMethod :: Disabled  => { 
211211                self . raw . set_ime_allowed ( false ) ; 
212212            } 
213-             InputMethod :: Allowed  | InputMethod :: Open  {  .. }  => { 
213+             InputMethod :: Allowed  {  position } 
214+             | InputMethod :: Open  {  position,  .. }  => { 
214215                self . raw . set_ime_allowed ( true ) ; 
216+                 self . raw . set_ime_cursor_area ( 
217+                     LogicalPosition :: new ( position. x ,  position. y ) , 
218+                     LogicalSize :: new ( 10 ,  10 ) ,  // TODO? 
219+                 ) ; 
215220            } 
216221        } 
217222
@@ -221,11 +226,6 @@ where
221226            preedit, 
222227        }  = input_method
223228        { 
224-             self . raw . set_ime_cursor_area ( 
225-                 LogicalPosition :: new ( position. x ,  position. y ) , 
226-                 LogicalSize :: new ( 10 ,  10 ) ,  // TODO? 
227-             ) ; 
228- 
229229            self . raw . set_ime_purpose ( conversion:: ime_purpose ( purpose) ) ; 
230230
231231            if  let  Some ( preedit)  = preedit { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments