예제 #1
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);
     }
     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);
         }
     }
     else if (Keyboard.GetKeyDown(KeyCode.Return) | Keyboard.GetKeyDown(KeyCode.KeypadEnter))
     {
         if (InputEvent.lineType != LineType.MultiLineNewline)
         {
             return(EditState.Finish);
         }
         else
         {
             return(EditState.NewLine);
         }
     }
     if (Keyboard.GetKeyDown(KeyCode.Escape))
     {
         return(EditState.Finish);
     }
     return(EditState.Continue);
 }
예제 #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);
 }