aboutsummaryrefslogtreecommitdiff
path: root/src/gui/Entry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/Entry.cpp')
-rw-r--r--src/gui/Entry.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/Entry.cpp b/src/gui/Entry.cpp
index f337bcf..7978b38 100644
--- a/src/gui/Entry.cpp
+++ b/src/gui/Entry.cpp
@@ -18,7 +18,7 @@ namespace gsr {
Entry::Entry(mgl::Font *font, const char *text, float max_width) : text("", *font), max_width(max_width) {
this->text.set_color(get_theme().text_color);
- set_string(text);
+ set_text(text);
}
bool Entry::on_event(mgl::Event &event, mgl::Window&, mgl::vec2f offset) {
@@ -32,12 +32,12 @@ namespace gsr {
std::string str = text.get_string();
const size_t prev_index = mgl::utf8_get_start_of_codepoint((const unsigned char*)str.c_str(), str.size(), str.size());
str.erase(prev_index, std::string::npos);
- set_string(std::move(str));
+ set_text(std::move(str));
}
} else if(event.type == mgl::Event::TextEntered && selected && event.text.codepoint >= 32) {
std::string str = text.get_string();
str.append(event.text.str, event.text.size);
- set_string(std::move(str));
+ set_text(std::move(str));
}
return true;
}
@@ -80,7 +80,7 @@ namespace gsr {
return { max_width, text.get_bounds().size.y + padding_top + padding_bottom };
}
- void Entry::set_string(std::string str) {
+ void Entry::set_text(std::string str) {
if(!validate_handler || validate_handler(str)) {
text.set_string(std::move(str));
caret_offset_x = text.find_character_pos(99999).x - this->text.get_position().x;
@@ -88,6 +88,10 @@ namespace gsr {
}
}
+ const std::string& Entry::get_text() const {
+ return text.get_string();
+ }
+
static bool is_number(uint8_t c) {
return c >= '0' && c <= '9';
}