SDK/TextAreaWidget: Make Write public

This commit is contained in:
Lynix 2016-12-05 16:48:29 +01:00
parent 2960157f8f
commit 6138c02b9b
2 changed files with 21 additions and 21 deletions

View File

@ -39,6 +39,8 @@ namespace Ndk
void SetText(const Nz::String& text);
void Write(const Nz::String& text);
TextAreaWidget& operator=(const TextAreaWidget&) = delete;
TextAreaWidget& operator=(TextAreaWidget&&) = default;
@ -53,8 +55,6 @@ namespace Ndk
void OnMouseExit() override;
void OnTextEntered(char32_t character, bool repeated) override;
void Write(const Nz::String& text);
EntityHandle m_cursorEntity;
EntityHandle m_textEntity;
Nz::SimpleTextDrawer m_drawer;

View File

@ -82,6 +82,25 @@ namespace Ndk
m_textSprite->Update(m_drawer);
}
void TextAreaWidget::Write(const Nz::String& text)
{
if (m_cursorPosition >= m_drawer.GetGlyphCount())
{
AppendText(text);
m_cursorPosition = m_drawer.GetGlyphCount();
}
else
{
Nz::String currentText = m_drawer.GetText();
currentText.Insert(currentText.GetCharacterPosition(m_cursorPosition), text);
SetText(currentText);
m_cursorPosition += text.GetLength();
}
RefreshCursor();
}
void TextAreaWidget::RefreshCursor()
{
std::size_t lineCount = m_drawer.GetLineCount();
@ -219,23 +238,4 @@ namespace Ndk
}
}
}
void TextAreaWidget::Write(const Nz::String& text)
{
if (m_cursorPosition >= m_drawer.GetGlyphCount())
{
AppendText(text);
m_cursorPosition = m_drawer.GetGlyphCount();
}
else
{
Nz::String currentText = m_drawer.GetText();
currentText.Insert(currentText.GetCharacterPosition(m_cursorPosition), text);
SetText(currentText);
m_cursorPosition += text.GetLength();
}
RefreshCursor();
}
}