From 6138c02b9b8edf4ef12a1dafac39a81e723eb76a Mon Sep 17 00:00:00 2001 From: Lynix Date: Mon, 5 Dec 2016 16:48:29 +0100 Subject: [PATCH] SDK/TextAreaWidget: Make Write public --- SDK/include/NDK/Widgets/TextAreaWidget.hpp | 4 +-- SDK/src/NDK/Widgets/TextAreaWidget.cpp | 38 +++++++++++----------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.hpp b/SDK/include/NDK/Widgets/TextAreaWidget.hpp index ca6d12fef..6a93fe248 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.hpp +++ b/SDK/include/NDK/Widgets/TextAreaWidget.hpp @@ -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; diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NDK/Widgets/TextAreaWidget.cpp index 04a6af718..6b141ebed 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/TextAreaWidget.cpp @@ -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(); - } }