/// <inheritdoc /> protected override void OnTextInput(TextInputEventArgs e) { base.OnTextInput(e); if (e.Handled) { return; } // Get connection RfbConnection?connection = Connection; if (connection == null) { return; } // Send chars one by one foreach (char c in e.Text) { KeySymbol keySymbol = KeyMapping.GetSymbolFromChar(c); // Press and release key if (!connection.EnqueueMessage(new KeyEventMessage(true, keySymbol))) { break; } connection.EnqueueMessage(new KeyEventMessage(false, keySymbol)); } e.Handled = true; }
private bool HandleKeyEvent(bool downFlag, Key key, KeyModifiers keyModifiers) { // Get connection RfbConnection?connection = Connection; if (connection == null) { return(false); } // Might this key be part of a shortcut? When modifies are present, OnTextInput doesn't get called, // so we have to handle printable characters here now, too. bool includePrintable = (keyModifiers & KeyModifiers.Control) != 0; // Get key symbol KeySymbol keySymbol = KeyMapping.GetSymbolFromKey(key, includePrintable); if (keySymbol == KeySymbol.Null) { return(false); } // Send key event to server bool queued = connection.EnqueueMessage(new KeyEventMessage(downFlag, keySymbol)); if (downFlag && queued) { _pressedKeys.Add(keySymbol); } else if (!downFlag) { _pressedKeys.Remove(keySymbol); } return(queued); }