示例#1
0
 internal void TriggerOnKeyRepeat(Keys key, float timeDown)
 {
     OnKeyRepeat?.Invoke(key, timeDown);
 }
示例#2
0
 public virtual void KeyRepeat(Key key)
 {
     OnKeyRepeat?.Invoke(key);
 }
示例#3
0
文件: Events.cs 项目: kuviman/Q
 static void InitEvents()
 {
     Log.Info("Registering window events");
     window.RenderFrame += (sender, e) => {
         timer.Tick();
         RenderState.SetupViewport();
         OnRender?.Invoke();
         State?.Render();
         window.SwapBuffers();
         FinalizeGLResources();
     };
     window.UpdateFrame += (sender, e) => {
         OnUpdate?.Invoke(e.Time);
         var state = State;
         if (state != null)
         {
             state.Update(e.Time);
             if (state.Closed)
             {
                 State = null;
             }
         }
         if (State == null)
         {
             Kill();
         }
     };
     window.KeyDown += (sender, e) => {
         var key = (Key)e.Key;
         if (e.IsRepeat)
         {
             OnKeyRepeat?.Invoke(key);
             State?.KeyRepeat(key);
         }
         else
         {
             OnKeyDown?.Invoke(key);
             State?.KeyDown(key);
         }
         if (e.Key == OpenTK.Input.Key.F4 && e.Modifiers.HasFlag(OpenTK.Input.KeyModifiers.Alt))
         {
             window.Close();
         }
     };
     window.KeyUp += (sender, e) => {
         OnKeyUp?.Invoke((Key)e.Key);
         State?.KeyUp((Key)e.Key);
     };
     window.KeyPress += (sender, e) => {
         OnCharInput?.Invoke(e.KeyChar);
         State?.CharInput(e.KeyChar);
     };
     window.MouseDown += (sender, e) => {
         OnMouseDown?.Invoke((MouseButton)e.Button, Mouse.Position);
         State?.MouseDown((MouseButton)e.Button, Mouse.Position);
     };
     window.MouseUp += (sender, e) => {
         OnMouseUp?.Invoke((MouseButton)e.Button, Mouse.Position);
         State?.MouseUp((MouseButton)e.Button, Mouse.Position);
     };
     window.MouseMove += (sender, e) => {
         OnMouseMove?.Invoke(Mouse.Position);
         State?.MouseMove(Mouse.Position);
     };
     window.MouseWheel += (sender, e) => {
         OnMouseWheel?.Invoke(e.DeltaPrecise);
         State?.MouseWheel(e.DeltaPrecise);
     };
     window.Resize += (sender, e) => {
         OpenTK.Graphics.OpenGL.GL.Viewport(0, 0, Width, Height);
     };
 }
示例#4
0
 protected void Invoke_OnKeyRepeat(object sender, KeyArgs args)
 {
     OnKeyRepeat?.Invoke(sender, args);
 }