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; } }
protected internal virtual void KeyDown(GUIKeyEventArgs args) { OnKeyDown?.Invoke(args); }
protected internal virtual void KeyHeld(GUIKeyEventArgs args) { }
protected virtual void KeyUp(GUIKeyEventArgs args) { }