Add ui::text_input event
This commit is contained in:
parent
6db913756b
commit
ccb5570892
6 changed files with 21 additions and 1 deletions
|
|
@ -31,6 +31,8 @@ namespace psemek::app
|
|||
void on_key_down(SDL_Keycode key) override;
|
||||
void on_key_up(SDL_Keycode key) override;
|
||||
|
||||
void on_text_input(std::string_view text) override;
|
||||
|
||||
void update() override;
|
||||
void present() override;
|
||||
|
||||
|
|
|
|||
|
|
@ -88,6 +88,12 @@ namespace psemek::app
|
|||
controller_.event(ui::key_press{key, false});
|
||||
}
|
||||
|
||||
void ui_scene::on_text_input(std::string_view text)
|
||||
{
|
||||
scene_base::on_text_input(text);
|
||||
controller_.event(ui::text_input{text});
|
||||
}
|
||||
|
||||
void ui_scene::update()
|
||||
{
|
||||
controller_.update(update_clock_.restart().count());
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ namespace psemek::ui
|
|||
bool event(mouse_click const & e);
|
||||
bool event(mouse_wheel const & e);
|
||||
bool event(key_press const & e);
|
||||
bool event(text_input const & e);
|
||||
|
||||
void update(float dt);
|
||||
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ namespace psemek::ui
|
|||
virtual bool on_event(mouse_click const &) { return false; }
|
||||
virtual bool on_event(mouse_wheel const &) { return false; }
|
||||
virtual bool on_event(key_press const &) { return false; }
|
||||
virtual bool on_event(text_input const &) { return false; }
|
||||
|
||||
virtual struct shape const & shape() const = 0;
|
||||
virtual void reshape(geom::box<float, 2> const & bbox) = 0;
|
||||
|
|
|
|||
|
|
@ -38,6 +38,11 @@ namespace psemek::ui
|
|||
bool down;
|
||||
};
|
||||
|
||||
using event_type_list = std::tuple<mouse_move, mouse_click, mouse_wheel, key_press>;
|
||||
struct text_input
|
||||
{
|
||||
std::string_view text;
|
||||
};
|
||||
|
||||
using event_type_list = std::tuple<mouse_move, mouse_click, mouse_wheel, key_press, text_input>;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -223,6 +223,11 @@ namespace psemek::ui
|
|||
return impl().event(e);
|
||||
}
|
||||
|
||||
bool controller::event(text_input const & e)
|
||||
{
|
||||
return impl().event(e);
|
||||
}
|
||||
|
||||
void controller::update(float dt)
|
||||
{
|
||||
impl().update(dt);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue