Ejemplo n.º 1
0
        private void HandleGuiInput(Godot.InputEvent input)
        {
            switch (input)
            {
            case Godot.InputEventKey keyEvent:
                var keyEventArgs = new GUIKeyEventArgs(this,
                                                       Keyboard.ConvertGodotKey(keyEvent.Scancode),
                                                       keyEvent.Echo,
                                                       keyEvent.Alt,
                                                       keyEvent.Control,
                                                       keyEvent.Shift,
                                                       keyEvent.Command);
                if (keyEvent.Pressed)
                {
                    KeyDown(keyEventArgs);
                }
                else
                {
                    KeyUp(keyEventArgs);
                }

                break;

            case Godot.InputEventMouseButton buttonEvent:
                if (buttonEvent.ButtonIndex >= (int)Godot.ButtonList.WheelUp &&
                    buttonEvent.ButtonIndex <= (int)Godot.ButtonList.WheelRight)
                {
                    // Mouse wheel event.
                    var mouseWheelEventArgs = new GUIMouseWheelEventArgs((Mouse.Wheel)buttonEvent.ButtonIndex,
                                                                         this,
                                                                         (Mouse.ButtonMask)buttonEvent.ButtonMask,
                                                                         buttonEvent.GlobalPosition.Convert(),
                                                                         buttonEvent.Position.Convert(),
                                                                         buttonEvent.Alt,
                                                                         buttonEvent.Control,
                                                                         buttonEvent.Shift,
                                                                         buttonEvent.Command);
                    MouseWheel(mouseWheelEventArgs);
                }
                else
                {
                    // Mouse button event.
                    var mouseButtonEventArgs = new GUIMouseButtonEventArgs((Mouse.Button)buttonEvent.ButtonIndex,
                                                                           buttonEvent.Doubleclick,
                                                                           this,
                                                                           (Mouse.ButtonMask)buttonEvent.ButtonMask,
                                                                           buttonEvent.GlobalPosition.Convert(),
                                                                           buttonEvent.Position.Convert(),
                                                                           buttonEvent.Alt,
                                                                           buttonEvent.Control,
                                                                           buttonEvent.Shift,
                                                                           buttonEvent.Command);
                    if (buttonEvent.Pressed)
                    {
                        MouseDown(mouseButtonEventArgs);
                    }
                    else
                    {
                        MouseUp(mouseButtonEventArgs);
                    }
                }

                break;

            case Godot.InputEventMouseMotion motionEvent:
                var mouseMoveEventArgs = new GUIMouseMoveEventArgs(motionEvent.Relative.Convert(),
                                                                   motionEvent.Speed.Convert(),
                                                                   this,
                                                                   (Mouse.ButtonMask)motionEvent.ButtonMask,
                                                                   motionEvent.GlobalPosition.Convert(),
                                                                   motionEvent.Position.Convert(),
                                                                   motionEvent.Alt,
                                                                   motionEvent.Control,
                                                                   motionEvent.Shift,
                                                                   motionEvent.Command);
                MouseMove(mouseMoveEventArgs);
                break;
            }
        }
Ejemplo n.º 2
0
 protected internal virtual void KeyDown(GUIKeyEventArgs args)
 {
     OnKeyDown?.Invoke(args);
 }
Ejemplo n.º 3
0
 protected internal virtual void KeyHeld(GUIKeyEventArgs args)
 {
 }
Ejemplo n.º 4
0
 protected virtual void KeyUp(GUIKeyEventArgs args)
 {
 }