@@ -691,9 +691,9 @@ void UpdateCaret(bool forceUpdate = false)
691691 Keyboard keyboard = Keyboard . current ;
692692 if ( keyboard != null )
693693 keyboard . SetIMECursorPosition ( cursorPos ) ;
694- #else
695- Input . compositionCursorPos = cursorPos ;
696694#endif
695+ Input . compositionCursorPos = cursorPos ;
696+
697697 }
698698
699699 _nextBlink = Time . time + 0.5f ;
@@ -1084,12 +1084,13 @@ void __focusIn(EventContext context)
10841084 Keyboard keyboard = Keyboard . current ;
10851085 if ( keyboard != null )
10861086 keyboard . SetIMEEnabled ( ! disableIME && ! _displayAsPassword ) ;
1087- #else
1087+ #endif
1088+ //Even using input system, we should use to the old input interface to enable IME (why)
10881089 if ( ! disableIME && ! _displayAsPassword )
10891090 Input . imeCompositionMode = IMECompositionMode . On ;
10901091 else
10911092 Input . imeCompositionMode = IMECompositionMode . Off ;
1092- #endif
1093+
10931094 _composing = 0 ;
10941095
10951096 if ( ( string ) context . data == "key" ) //select all if got focus by tab key
@@ -1125,9 +1126,9 @@ void __focusOut(EventContext contxt)
11251126 Keyboard keyboard = Keyboard . current ;
11261127 if ( keyboard != null )
11271128 keyboard . SetIMEEnabled ( true ) ;
1128- #else
1129- Input . imeCompositionMode = IMECompositionMode . Auto ;
11301129#endif
1130+ Input . imeCompositionMode = IMECompositionMode . Auto ;
1131+
11311132 TextInputHistory . inst . StopRecord ( this ) ;
11321133 }
11331134
@@ -1398,38 +1399,43 @@ bool HandleKey(InputEvent evt)
13981399 char c = evt . character ;
13991400 if ( c != 0 )
14001401 {
1401- if ( evt . ctrlOrCmd )
1402- return true ;
1402+ #if FAIRYGUI_INPUT_SYSTEM
1403+ if ( ! evt . ctrlOrCmd && ( c == '\n ' || c == '\r ' || c == '\t ' || c == 25 || c == 3 ) )
1404+ HandleTextInput ( c ) ;
1405+ #else
1406+ if ( ! evt . ctrlOrCmd )
1407+ HandleTextInput ( c ) ;
1408+ #endif
1409+ return true ;
1410+ }
1411+ else
1412+ return keyCodeHandled ;
1413+ }
14031414
1404- if ( c == '\r ' || c == 3 )
1405- c = '\n ' ;
1415+ void HandleTextInput ( char c )
1416+ {
1417+ if ( c == '\r ' || c == 3 )
1418+ c = '\n ' ;
14061419
1407- if ( c == 25 ) /*shift+tab*/
1408- c = '\t ' ;
1420+ if ( c == 25 ) /*shift+tab*/
1421+ c = '\t ' ;
14091422
1410- if ( c == 27 /*escape*/ || textField . singleLine && ( c == '\n ' || c == '\t ' ) )
1411- return true ;
1423+ if ( c == 27 /*escape*/ || textField . singleLine && ( c == '\n ' || c == '\t ' ) )
1424+ return ;
14121425
1426+ if ( _editable )
1427+ {
14131428 if ( char . IsHighSurrogate ( c ) )
14141429 {
14151430 _highSurrogateChar = c ;
1416- return true ;
1417- }
1418-
1419- #if ! FAIRYGUI_INPUT_SYSTEM
1420- if ( _editable )
1421- {
1422- if ( char . IsLowSurrogate ( c ) )
1423- ReplaceSelection ( char . ConvertFromUtf32 ( ( ( int ) c & 0x03FF ) + ( ( ( ( int ) _highSurrogateChar & 0x03FF ) + 0x40 ) << 10 ) ) ) ;
1424- else
1425- ReplaceSelection ( c . ToString ( ) ) ;
1431+ return ;
14261432 }
1427- #endif
14281433
1429- return true ;
1434+ if ( char . IsLowSurrogate ( c ) )
1435+ ReplaceSelection ( char . ConvertFromUtf32 ( ( ( int ) c & 0x03FF ) + ( ( ( ( int ) _highSurrogateChar & 0x03FF ) + 0x40 ) << 10 ) ) ) ;
1436+ else
1437+ ReplaceSelection ( c . ToString ( ) ) ;
14301438 }
1431- else
1432- return keyCodeHandled ;
14331439 }
14341440
14351441 void CheckComposition ( )
@@ -1563,9 +1569,18 @@ static void OnIMECompositionChange(IMECompositionString composition)
15631569
15641570 static void OnTextInput ( char c )
15651571 {
1572+ // filter control chars
1573+ // if Active input handling is BOTH, we will receive these controls chars in this callback
1574+ // howeveer, if Active input handling is New, we will not receive these controls chars in this callback
1575+ if ( c < 32 && c != 3 && c != '\t ' && c != '\n ' && c != '\r ' && c != 25
1576+ || c >= 127 && c <= 159
1577+ || c >= 63232 && c <= 63235 //why arrow keys have these codes?
1578+ )
1579+ return ;
1580+
15661581 var focus = Stage . inst . focus ;
1567- if ( ( focus is InputTextField ) && ( ( InputTextField ) focus ) . editable && ! ( ( InputTextField ) focus ) . keyboardInput )
1568- ( ( InputTextField ) focus ) . ReplaceSelection ( c . ToString ( ) ) ;
1582+ if ( ( focus is InputTextField ) && ! ( ( InputTextField ) focus ) . keyboardInput )
1583+ ( ( InputTextField ) focus ) . HandleTextInput ( c ) ;
15691584 }
15701585
15711586 /// <summary>
0 commit comments