public static void OnKeyDown(Keys key) { KeyDown.Invoke(key); if (IsMenuBarActive) { MenuBar.OnKeyDown(key); } else { // Small workaround: if key is escape active widget is window // Send it there var topWidget = GetTopWidget(); var asWindow = topWidget as Window; if (asWindow != null) { if (key == Keys.Escape) { asWindow.OnKeyDown(key); } var asDialog = asWindow as Dialog; if (asDialog != null && key == Keys.Enter) { // Dialog also always receives Enter (Ok) asWindow.OnKeyDown(key); } } if (_focusedKeyboardWidget != null && _focusedKeyboardWidget.Active) { _focusedKeyboardWidget.OnKeyDown(key); #if XENKO var ch = key.ToChar(_downKeys.Contains(Keys.LeftShift) || _downKeys.Contains(Keys.RightShift)); if (ch != null) { _focusedKeyboardWidget.OnChar(ch.Value); } #endif } } if (key == Keys.Escape && ContextMenu != null) { HideContextMenu(); } #if MONOGAME if (!HasExternalTextInput && !IsControlDown && !IsAltDown) { var c = key.ToChar(IsShiftDown); if (c != null) { OnChar(c.Value); } } #endif }
private void OnChar(char c) { var ev = Char; if (ev != null) { ev(this, new GenericEventArgs <char>(c)); } if (_focusedKeyboardWidget != null) { _focusedKeyboardWidget.OnChar(c); } }
public void OnKeyDown(Keys key) { KeyDown.Invoke(this, key); if (MenuBar != null && MyraEnvironment.ShowUnderscores) { MenuBar.OnKeyDown(key); } else { // Small workaround: if key is escape active widget is window // Send it there var asWindow = GetTopWidget(false) as Window; if (asWindow != null && key == Keys.Escape && _focusedKeyboardWidget != asWindow) { asWindow.OnKeyDown(key); } if (_focusedKeyboardWidget != null) { _focusedKeyboardWidget.OnKeyDown(key); #if XENKO var ch = key.ToChar(_downKeys.Contains(Keys.LeftShift) || _downKeys.Contains(Keys.RightShift)); if (ch != null) { _focusedKeyboardWidget.OnChar(ch.Value); } #endif } } if (key == Keys.Escape && ContextMenu != null) { HideContextMenu(); } #if MONOGAME if (!HasExternalTextInput && !IsControlDown && !IsAltDown) { var c = key.ToChar(IsShiftDown); if (c != null) { OnChar(c.Value); } } #endif }
public void OnKeyDown(Keys key) { KeyDown.Invoke(key); if (IsMenuBarActive) { MenuBar.OnKeyDown(key); } else { if (_focusedKeyboardWidget != null && _focusedKeyboardWidget.Active) { _focusedKeyboardWidget.OnKeyDown(key); #if STRIDE var ch = key.ToChar(_downKeys.Contains(Keys.LeftShift) || _downKeys.Contains(Keys.RightShift)); if (ch != null) { _focusedKeyboardWidget.OnChar(ch.Value); } #elif MONOGAME if (!HasExternalTextInput && !IsControlDown && !IsAltDown) { var c = key.ToChar(IsShiftDown); if (c != null) { OnChar(c.Value); } } #endif } } if (key == Keys.Escape && ContextMenu != null) { HideContextMenu(); } }