overlays: implement osk delete action

This commit is contained in:
Megamouse 2022-10-29 22:17:24 +02:00
parent ad340c3007
commit eccceea7fb
4 changed files with 32 additions and 0 deletions

View file

@ -173,6 +173,27 @@ namespace rsx
refresh();
}
void edit_text::del()
{
if (caret_position >= text.length())
{
return;
}
if (caret_position == 0)
{
value = value.length() > 1 ? value.substr(1) : U"";
}
else
{
value = value.substr(0, caret_position) + value.substr(caret_position + 1);
}
m_reset_caret_pulse = true;
set_unicode_text(value);
refresh();
}
compiled_resource& edit_text::get_compiled()
{
if (!is_compiled)

View file

@ -33,6 +33,7 @@ namespace rsx
void move_caret(direction dir);
void insert_text(const std::u32string& str);
void erase();
void del();
compiled_resource& get_compiled() override;
};

View file

@ -700,6 +700,9 @@ namespace rsx
case CELL_KEYC_BS:
on_backspace(key);
break;
case CELL_KEYC_DELETE:
on_delete(key);
break;
case CELL_KEYC_ESCAPE:
Close(CELL_OSKDIALOG_CLOSE_CANCEL);
break;
@ -812,6 +815,12 @@ namespace rsx
on_text_changed();
}
void osk_dialog::on_delete(const std::u32string&)
{
m_preview.del();
on_text_changed();
}
void osk_dialog::on_enter(const std::u32string&)
{
if (!(flags & CELL_OSKDIALOG_NO_RETURN))

View file

@ -104,6 +104,7 @@ namespace rsx
void on_layer(const std::u32string&);
void on_space(const std::u32string&);
void on_backspace(const std::u32string&);
void on_delete(const std::u32string&);
void on_enter(const std::u32string&);
std::u32string get_placeholder() const;