Skip to content

Commit

Permalink
Call SDL3 start/stop text input.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugh Sanderson committed Dec 12, 2024
1 parent a0406e2 commit 472bf27
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions project/include/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ class Stage : public DisplayObjectContainer

virtual void setTitle(const std::string &) { }
virtual std::string getTitle() { return ""; }
virtual void setTextInput(bool enable) { }


DisplayObject *GetFocusObject() { return mFocusObject; }
Expand Down
1 change: 1 addition & 0 deletions project/include/TextField.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ class TextField : public DisplayObject
bool IsCacheDirty();
void SyncSelection();
void Focus();
void Unfocus();
void setCaretIndex(int inIndex);


Expand Down
10 changes: 10 additions & 0 deletions project/src/common/TextField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,19 @@ void TextField::setSelection(int inStartIndex, int inEndIndex)
SyncSelection();
}

void TextField::Unfocus()
{
Stage *stage = getStage();
if (stage)
stage->setTextInput(false);
}


void TextField::Focus()
{
Stage *stage = getStage();
if (stage)
stage->setTextInput(true);
#if defined(IPHONE) || defined (ANDROID) || defined(WEBOS) || defined(BLACKBERRY) || defined(TIZEN)
if (needsSoftKeyboard)
{
Expand Down
10 changes: 10 additions & 0 deletions project/src/sdl2/SDL2Stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,16 @@ class SDLStage : public Stage
SDL_SetWindowFullscreen(mSDLWindow, FullscreenMode);
#endif
}

void setTextInput(bool enable)
{
#ifdef NME_SDL3
if (enable)
SDL_StartTextInput(mSDLWindow);
else
SDL_StopTextInput(mSDLWindow);
#endif
}


void SetScreenMode(ScreenMode m)
Expand Down

0 comments on commit 472bf27

Please sign in to comment.