示例#1
0
        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]);
            }
        }
示例#2
0
        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));
        }
示例#3
0
        /// <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);
            }
        }
示例#4
0
 private void Input_TextInput(TextInputEvent data)
 {
     if (!IsDisposed)
     {
         if (SelectedElement != null && SelectedElement.IsKeyboardEventTrigger)
         {
             SelectedElement.TriggerOnTextInput(data);
         }
     }
 }
示例#5
0
        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);
        }
示例#6
0
        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;
            }
        }
示例#7
0
 public static int AddTextInputEvent(TextInputEvent e)
 {
     _textEvents.Add(e);
     Refresh();
     return(_textEvents.Count - 1);
 }
示例#8
0
 private bool TextInput(TextInputEvent e)
 {
     ImGui.GetIO().AddInputCharacter((uint)e.Unicode);
     return(false);
 }
示例#9
0
 public virtual bool OnTextInput(TextInputEvent e)
 {
     return(false);
 }
示例#10
0
 private static void Window_TextInput(GameWindow window, TextInputEvent ev)
 {
     TextInput?.Invoke(window, ev);
 }
示例#11
0
 public static void ClearEvent()
 {
     container.Clear();
     UserAction.ClearAll();
     TextInputEvent.Reset();
 }