Widget::textLength() returns the number of (Unicode) characters in the text field

This commit is contained in:
David Capello 2016-03-14 12:38:11 -03:00
parent fb6a1481f9
commit 29f6db6f35
2 changed files with 7 additions and 1 deletions

View File

@ -13,6 +13,7 @@
#include "ui/widget.h"
#include "base/memory.h"
#include "base/string.h"
#include "she/display.h"
#include "she/font.h"
#include "she/surface.h"
@ -124,6 +125,11 @@ double Widget::textDouble() const
return strtod(m_text.c_str(), NULL);
}
int Widget::textLength() const
{
return base::utf8_length(text());
}
void Widget::setText(const std::string& text)
{
setTextQuiet(text);

View File

@ -82,7 +82,7 @@ namespace ui {
const std::string& text() const { return m_text; }
int textInt() const;
double textDouble() const;
std::size_t textLength() const { return m_text.size(); }
int textLength() const;
void setText(const std::string& text);
void setTextf(const char* text, ...);
void setTextQuiet(const std::string& text);