From fd49d7a01f0d70c5fe33fdb947dbd77c8cb678c0 Mon Sep 17 00:00:00 2001 From: qiuguohua Date: Fri, 13 Oct 2023 09:40:07 +0800 Subject: [PATCH] Turning off textinput when using SDL --- native/cocos/platform/SDLHelper.cpp | 6 ++++++ native/cocos/ui/edit-box/EditBox-mac.mm | 4 ---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/native/cocos/platform/SDLHelper.cpp b/native/cocos/platform/SDLHelper.cpp index 64600cca281..71896c205bc 100644 --- a/native/cocos/platform/SDLHelper.cpp +++ b/native/cocos/platform/SDLHelper.cpp @@ -158,6 +158,12 @@ int SDLHelper::init() { CC_LOG_ERROR("SDL could not initialize! SDL_Error: %s\n", SDL_GetError()); return -1; } + // (1) Disable IDE on windows platform. + // (2) On mac platform, SDL has an internal implementation of textinput , + // which internally sends the SDL_TEXTINPUT event. Causing two events to be sent. + // So we need to stop the implementation of TextInput. + // (3) Other platforms do not use textinput in sdl. + stopTextInput(); return 0; } diff --git a/native/cocos/ui/edit-box/EditBox-mac.mm b/native/cocos/ui/edit-box/EditBox-mac.mm index 8b160e5e9a4..e6280e3e664 100644 --- a/native/cocos/ui/edit-box/EditBox-mac.mm +++ b/native/cocos/ui/edit-box/EditBox-mac.mm @@ -242,10 +242,6 @@ void initTextField(const cc::EditBox::ShowInfo &showInfo) { } void init(const cc::EditBox::ShowInfo &showInfo) { - // SDL has an internal implementation of textinput , - // which internally sends the SDL_TEXTINPUT event. Causing two events to be sent. - // So we need to stop the implementation of TextInput. - cc::SDLHelper::stopTextInput(); if (showInfo.isMultiline) initTextView(showInfo); else