Add text input helpers in ui::element
This commit is contained in:
parent
ccb5570892
commit
7848d5a8b3
2 changed files with 21 additions and 0 deletions
|
|
@ -81,6 +81,10 @@ namespace psemek::ui
|
|||
virtual std::shared_ptr<struct style const> merged_style() const;
|
||||
virtual std::shared_ptr<struct style const> 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;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include <psemek/log/log.hpp>
|
||||
|
||||
#include <SDL2/SDL_keyboard.h>
|
||||
|
||||
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<std::string> element::set_hint(std::optional<std::string> hint)
|
||||
{
|
||||
std::swap(hint_, hint);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue