private void HandleKeyPressEvent(object o, KeyPressEventArgs args) { var key = (Common.Configuration.Hid.Key)GTK3MappingHelper.ToInputKey(args.Event.Key); if (!(KeyPressedEvent?.Invoke(key)).GetValueOrDefault(true)) { return; } if (_canProcessInput) { _inputToTextEntry.SendKeyPressEvent(o, args); _inputToTextEntry.GetSelectionBounds(out int selectionStart, out int selectionEnd); TextChangedEvent?.Invoke(_inputToTextEntry.Text, selectionStart, selectionEnd, _inputToTextEntry.OverwriteMode); } }
private void HandleKeyReleaseEvent(object o, KeyReleaseEventArgs args) { var key = (Common.Configuration.Hid.Key)GTK3MappingHelper.ToInputKey(args.Event.Key); if (!(KeyReleasedEvent?.Invoke(key)).GetValueOrDefault(true)) { return; } if (_canProcessInput) { // TODO (caian): This solution may have problems if the pause is sent after a key press // and before a key release. But for now GTK Entry does not seem to use release events. _inputToTextEntry.SendKeyReleaseEvent(o, args); _inputToTextEntry.GetSelectionBounds(out int selectionStart, out int selectionEnd); TextChangedEvent?.Invoke(_inputToTextEntry.Text, selectionStart, selectionEnd, _inputToTextEntry.OverwriteMode); } }