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 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); } }