diff --git a/libs/ui/include/psemek/ui/element.hpp b/libs/ui/include/psemek/ui/element.hpp index eac11050..71f547ff 100644 --- a/libs/ui/include/psemek/ui/element.hpp +++ b/libs/ui/include/psemek/ui/element.hpp @@ -81,6 +81,10 @@ namespace psemek::ui virtual std::shared_ptr merged_style() const; virtual std::shared_ptr merged_own_style() const; + static bool in_text_input(); + static void start_text_input(); + static void stop_text_input(); + private: element * parent_ = nullptr; async::event_loop * loop_ = nullptr; diff --git a/libs/ui/source/element.cpp b/libs/ui/source/element.cpp index f041079e..6a9aa1a0 100644 --- a/libs/ui/source/element.cpp +++ b/libs/ui/source/element.cpp @@ -4,6 +4,8 @@ #include +#include + namespace psemek::ui { @@ -139,6 +141,21 @@ namespace psemek::ui return merged_own_style_; } + bool element::in_text_input() + { + return SDL_IsTextInputActive() == SDL_TRUE; + } + + void element::start_text_input() + { + SDL_StartTextInput(); + } + + void element::stop_text_input() + { + SDL_StopTextInput(); + } + std::optional element::set_hint(std::optional hint) { std::swap(hint_, hint);