Exemplo n.º 1
0
        protected override unsafe void HandleTextInputEvent(SDL.SDL_TextInputEvent evtText)
        {
            if (!SDL2Extensions.TryGetStringFromBytePointer(evtText.text, out string sdlResult))
            {
                return;
            }

            // Block SDL text input if it was already handled by `handleImeMessage()`.
            // SDL truncates text over 32 bytes and sends it as multiple events.
            // We assume these events will be handled in the same `pollSDLEvents()` call.
            if (lastImeResult?.Contains(sdlResult) == true)
            {
                // clear the result after this SDL event loop finishes so normal text input isn't blocked.
                EventScheduler.AddOnce(() => lastImeResult = null);
                return;
            }

            // also block if there is an ongoing composition (unlikely to occur).
            if (imeCompositionActive)
            {
                return;
            }

            base.HandleTextInputEvent(evtText);
        }
Exemplo n.º 2
0
        private unsafe void OnTextInputActions(SDL.SDL_TextInputEvent e)
        {
            var textInputEvent = InputEventPool <TextInputEvent> .GetOrCreate(this);

            textInputEvent.Text = SDLBufferToString(e.text);
            textInputEvent.Type = TextInputEventType.Input;
            textEvents.Add(textInputEvent);
        }
Exemplo n.º 3
0
        protected override void HandleTextInputEvent(SDL.SDL_TextInputEvent evtText)
        {
            // block SDL text input if there was a recent result from `handleImeMessage()`.
            if (recentImeResult)
            {
                recentImeResult = false;
                return;
            }

            // also block if there is an ongoing composition (unlikely to occur).
            if (imeCompositionActive)
            {
                return;
            }

            base.HandleTextInputEvent(evtText);
        }