SDK/TextAreaWidget: Make Write public
This commit is contained in:
parent
2960157f8f
commit
6138c02b9b
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue