protected virtual void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs e) { if (e.Key == OpenTK.Input.Key.LShift) { _modifierKeys |= ModifierKeys.LShift; } if (e.Key == OpenTK.Input.Key.RShift) { _modifierKeys |= ModifierKeys.RShift; } if (e.Key == OpenTK.Input.Key.LControl) { _modifierKeys |= ModifierKeys.LControl; } if (e.Key == OpenTK.Input.Key.RControl) { _modifierKeys |= ModifierKeys.RControl; } if (e.Key == OpenTK.Input.Key.LAlt) { _modifierKeys |= ModifierKeys.LAlt; } if (e.Key == OpenTK.Input.Key.RAlt) { _modifierKeys |= ModifierKeys.RAlt; } if (FocusedElement != null) { if (FocusedElement.ReceiveMouseClicks) { if (e.Key == LeftMouseKey) { FocusedElement.MouseDown(LEFT_CLICK_DOWN); FocusedElement.MouseDown(LEFT_CLICK_UP); } else if (e.Key == RightMouseKey) { FocusedElement.MouseDown(RIGHT_CLICK_DOWN); FocusedElement.MouseDown(RIGHT_CLICK_UP); } else if (e.Key == MiddleMouseKey) { FocusedElement.MouseDown(MIDDLE_CLICK_DOWN); FocusedElement.MouseDown(MIDDLE_CLICK_UP); } } else if (FocusedElement.ReceiveKeys) { FocusedElement.KeyDown(e, _modifierKeys); } } if (Receiver != null && ShouldNotifyReceiver()) { Receiver.KeyDown(e, _modifierKeys); } }
protected virtual void Mouse_ButtonDown(object sender, OpenTK.Input.MouseButtonEventArgs e) { if (FocusedElement != HoveredElement) { if (FocusedElement != null) { FocusedElement.Deactivate(); } FocusedElement = HoveredElement; } if (FocusedElement != null) { FocusedElement.Activate(); FocusedElement.MouseDown(e); } //Mouse_Move(sender, new OpenTK.Input.MouseMoveEventArgs(e.X, e.Y, 0, 0)); }
protected virtual void Mouse_ButtonDown(object sender, OpenTK.Input.MouseButtonEventArgs e) { FocusedElement = HoveredElement; if (FocusedElement != null && FocusedElement.Draggable) { _lastMousePosition.X = e.X; _lastMousePosition.Y = e.Y; _draggedElement = FocusedElement; } else if (FocusedElement != null && FocusedElement.ReceiveMouseClicks) { FocusedElement.MouseDown(e); } if (Receiver != null && ShouldNotifyReceiver()) { Receiver.MouseDown(e); } Mouse_Move(sender, new OpenTK.Input.MouseMoveEventArgs(e.X, e.Y, 0, 0)); }
protected virtual void Keyboard_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs e) { if (e.Key == OpenTK.Input.Key.LShift) { _modifierKeys |= ModifierKeys.LShift; } if (e.Key == OpenTK.Input.Key.RShift) { _modifierKeys |= ModifierKeys.RShift; } if (e.Key == OpenTK.Input.Key.LControl) { _modifierKeys |= ModifierKeys.LControl; } if (e.Key == OpenTK.Input.Key.RControl) { _modifierKeys |= ModifierKeys.RControl; } if (e.Key == OpenTK.Input.Key.LAlt) { _modifierKeys |= ModifierKeys.LAlt; } if (e.Key == OpenTK.Input.Key.RAlt) { _modifierKeys |= ModifierKeys.RAlt; } /** * Modifiers ok, testing keys **/ if (e.Key == NextWidgetKey && IsModifierOk(NextWidgetKeyModifier)) { if (FocusedElement == null) { GameObject firstObject = FindFirstGameObject(); if (firstObject != null) { FocusedElement = firstObject.GetComponent <Widget>(); FocusedElement.MouseEnter(); } } else if (FocusedElement.NextWidget != null) { FocusedElement.MouseLeave(); FocusedElement = FocusedElement.NextWidget; FocusedElement.MouseEnter(); } } if (e.Key == PreviousWidgetKey && IsModifierOk(PreviousWidgetKeyModifier)) { if (FocusedElement == null) { GameObject firstObject = FindFirstGameObject(); if (firstObject != null) { FocusedElement = firstObject.GetComponent <Widget>(); FocusedElement.MouseEnter(); } } else if (FocusedElement.PreviousWidget != null) { FocusedElement.MouseLeave(); FocusedElement = FocusedElement.PreviousWidget; FocusedElement.MouseEnter(); } } if (FocusedElement != null) { if (e.Key == LeftMouseKey && IsModifierOk(LeftMouseKeyModifier)) { FocusedElement.MouseDown(LEFT_CLICK_DOWN); FocusedElement.MouseUp(LEFT_CLICK_UP); } else if (e.Key == RightMouseKey && IsModifierOk(RightMouseKeyModifier)) { FocusedElement.MouseDown(RIGHT_CLICK_DOWN); FocusedElement.MouseUp(RIGHT_CLICK_UP); } else if (e.Key == MiddleMouseKey && IsModifierOk(MiddleMouseKeyModifier)) { FocusedElement.MouseDown(MIDDLE_CLICK_DOWN); FocusedElement.MouseUp(MIDDLE_CLICK_UP); } FocusedElement.KeyDown(e, _modifierKeys); } }