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); }