private static unsafe void ProcessTextInputEvent(Sdl2NativeWindow window, TextInputEvent ev) { // Calculate the length of the typed text string int length; for (length = 0; length < TextInputEvent.TextSize && ev.Text[length] != '\0'; length++) { ; } // Make sure we have enough space to decode this string int decoded_length = Encoding.UTF8.GetCharCount(ev.Text, length); if (window.DecodeTextBuffer.Length < decoded_length) { Array.Resize( ref window.DecodeTextBuffer, 2 * Math.Max(decoded_length, window.DecodeTextBuffer.Length)); } // Decode the string from UTF8 to .Net UTF16 fixed(char *pBuffer = window.DecodeTextBuffer) { decoded_length = System.Text.Encoding.UTF8.GetChars( ev.Text, length, pBuffer, window.DecodeTextBuffer.Length); } for (int i = 0; i < decoded_length; i++) { window.OnKeyPress(window.DecodeTextBuffer[i]); } }
public static void DispatchEvent() { DateTime now = DateTime.Now; Ticks = now.Ticks; int s = now.Millisecond; int t = s - LastTime; if (t < 0) { t += 1000; } TimeSlice = t; LastTime = s; EventCallBack.Rolling(); if (inputType == InputType.OnlyMouse) { DispatchMouse(); } else if (inputType == InputType.OnlyTouch) { DispatchTouch(); } else { DispatchWin(); } TextInputEvent.Dispatch(); GestureEvent.Dispatch(new List <UserAction>(inputs)); }
/// <summary> /// Triggered by runtime when character is input. /// </summary> /// <param name="textChar">Code of input character.</param> /// <param name="isUsed">Set to true if the event was handled previously by some internal system (like GUI).</param> private static void Internal_TriggerCharInput(int textChar, bool isUsed) { TextInputEvent ev = new TextInputEvent(textChar, isUsed); if (OnCharInput != null) { OnCharInput(ev); } }
private void Input_TextInput(TextInputEvent data) { if (!IsDisposed) { if (SelectedElement != null && SelectedElement.IsKeyboardEventTrigger) { SelectedElement.TriggerOnTextInput(data); } } }
public void DeserializeTextInputEvent() { /* GIVEN */ var deserialized = new TextInputEvent(); /* WHEN */ deserialized.Deserialize(serializedEvent); /* THEN */ TestCommonAttributes(deserialized); Assert.AreEqual(deserialized.InputtedText, "SomeInput"); Assert.AreEqual("SomeLabel", deserialized.Textbox); }
private void UITextArea_OnTextInput(UIElement sender, TextInputEvent data) { if (!ValidateInput(InputSource.TextInput, data.Character)) { return; } void AppendCharAfterCaret(char value) { InsertChar(Value.Length, value); } switch (data.Key) { case Keys.Tab: for (int i = 0; i < 4; i++) { AppendCharAfterCaret(' '); } break; case Keys.Back: if (Value.Length > 0) { Remove(Value.Length - 1, 1); } break; case Keys.Enter: if (_isMultiLined) { AppendCharAfterCaret('\n'); } break; default: char c = (char)data.Character; if (char.IsLetter(c) || char.IsNumber(c) || char.IsSymbol(c) || char.IsWhiteSpace(c) || char.IsPunctuation(c)) { AppendCharAfterCaret(c); } break; } }
public static int AddTextInputEvent(TextInputEvent e) { _textEvents.Add(e); Refresh(); return(_textEvents.Count - 1); }
private bool TextInput(TextInputEvent e) { ImGui.GetIO().AddInputCharacter((uint)e.Unicode); return(false); }
public virtual bool OnTextInput(TextInputEvent e) { return(false); }
private static void Window_TextInput(GameWindow window, TextInputEvent ev) { TextInput?.Invoke(window, ev); }
public static void ClearEvent() { container.Clear(); UserAction.ClearAll(); TextInputEvent.Reset(); }