Пример #1
0
        internal static void SubDispatch()
        {
            if (InputEvent != null)
            {
                if (!InputEvent.ReadOnly)
                {
                    if (!InputEvent.Pressed)
                    {
                        if (KeyPressed() == EditState.Continue)
                        {
                            if (Keyboard.InputChanged)
                            {
                                if (Keyboard.InputString == "")
                                {
                                    return;
                                }
#if UNITY_EDITOR || UNITY_STANDALONE_WIN
                                if (Keyboard.Nokey())
                                {
                                    InputEvent.OnInputChanged(IME.CurrentCompStr());
                                }
                                else
                                {
                                    InputEvent.OnInputChanged(Keyboard.InputString);
                                }
#else
                                InputEvent.OnInputChanged(Keyboard.InputString);
#endif
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
 static EditState KeyPressed()
 {
     KeyPressTime -= UserAction.TimeSlice;
     if (Keyboard.GetKey(KeyCode.Backspace))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.Delete(-1);
             }
             KeySpeed *= 0.8f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.Delete))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.Delete(1);
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.LeftArrow))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.SetSelectPoint(-1);
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.RightArrow))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.SetSelectPoint(1);
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.UpArrow))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.MoveUp();
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.DownArrow))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.MoveDown();
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     KeySpeed = 220f;
     if (Keyboard.GetKeyDown(KeyCode.Home))
     {
         InputEvent.SetSelectPoint(0);
         return(EditState.Done);
     }
     if (Keyboard.GetKeyDown(KeyCode.End))
     {
         InputEvent.SetSelectPoint(10000000);
         return(EditState.Done);
     }
     if (Keyboard.GetKeyDown(KeyCode.A))
     {
         if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl))
         {
             if (InputEvent != null)
             {
                 InputEvent.textInfo.startSelect = 0;
                 InputEvent.textInfo.endSelect   = InputEvent.textInfo.text.Length;
                 InputEvent.Selected();
             }
             return(EditState.Done);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.X))//剪切
     {
         if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl))
         {
             if (InputEvent != null)
             {
                 string str = InputEvent.SelectString;
                 InputEvent.Delete(-1);
                 ThreadMission.InvokeToMain((o) => { GUIUtility.systemCopyBuffer = str; }, null);
             }
             return(EditState.Done);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.C))//复制
     {
         if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl))
         {
             if (InputEvent != null)
             {
                 string str = InputEvent.SelectString;
                 ThreadMission.InvokeToMain((o) => { GUIUtility.systemCopyBuffer = str; }, null);
             }
             return(EditState.Done);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.V))//粘贴
     {
         if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl))
         {
             if (InputEvent != null)
             {
                 InputEvent.OnInputChanged(Keyboard.systemCopyBuffer);
             }
             return(EditState.Done);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.Return) | Keyboard.GetKeyDown(KeyCode.KeypadEnter))
     {
         if (InputEvent.lineType == LineType.MultiLineNewline)
         {
             if (Keyboard.GetKey(KeyCode.RightControl))
             {
                 return(EditState.Finish);
             }
             return(EditState.NewLine);
         }
         else
         {
             return(EditState.Finish);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.Escape))
     {
         return(EditState.Finish);
     }
     return(EditState.Continue);
 }
Пример #3
0
 static EditState KeyPressed()
 {
     KeyPressTime -= UserAction.TimeSlice;
     if (Keyboard.GetKey(KeyCode.Backspace))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.DeleteLast();
                 InputEvent.SetShowText();
             }
             KeySpeed *= 0.8f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.Delete))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.DeleteNext();
                 InputEvent.SetShowText();
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.LeftArrow))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.PointerMoveLeft();
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.RightArrow))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.PointerMoveRight();
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.UpArrow))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.PointerMoveUp();
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     if (Keyboard.GetKey(KeyCode.DownArrow))
     {
         if (KeyPressTime <= 0)
         {
             if (InputEvent != null)
             {
                 InputEvent.PointerMoveDown();
             }
             KeySpeed *= 0.7f;
             if (KeySpeed < MaxSpeed)
             {
                 KeySpeed = MaxSpeed;
             }
             KeyPressTime = KeySpeed;
         }
         return(EditState.Done);
     }
     KeySpeed = 220f;
     if (Keyboard.GetKeyDown(KeyCode.Home))
     {
         InputEvent.PointerMoveStart();
         return(EditState.Done);
     }
     if (Keyboard.GetKeyDown(KeyCode.End))
     {
         InputEvent.PointerMoveEnd();
         return(EditState.Done);
     }
     if (Keyboard.GetKeyDown(KeyCode.A))
     {
         if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl))
         {
             if (InputEvent != null)
             {
                 InputEvent.SelectAll();
             }
             return(EditState.Done);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.X))//剪切
     {
         if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl))
         {
             if (InputEvent != null)
             {
                 string str = InputEvent.GetSelectString();
                 InputEvent.DeleteSelectString();
                 GUIUtility.systemCopyBuffer = str;
                 InputEvent.SetShowText();
             }
             return(EditState.Done);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.C))//复制
     {
         if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl))
         {
             if (InputEvent != null)
             {
                 string str = InputEvent.GetSelectString();
                 GUIUtility.systemCopyBuffer = str;
             }
             return(EditState.Done);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.V))//粘贴
     {
         if (Keyboard.GetKey(KeyCode.LeftControl) | Keyboard.GetKey(KeyCode.RightControl))
         {
             if (InputEvent != null)
             {
                 InputEvent.OnInputChanged(Keyboard.systemCopyBuffer);
             }
             return(EditState.Done);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.Return) | Keyboard.GetKeyDown(KeyCode.KeypadEnter))
     {
         if (InputEvent.lineType == LineType.MultiLineNewline)
         {
             if (Keyboard.GetKey(KeyCode.RightControl))
             {
                 return(EditState.Finish);
             }
             return(EditState.NewLine);
         }
         else
         {
             return(EditState.Finish);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.Escape))
     {
         return(EditState.Finish);
     }
     return(EditState.Continue);
 }