diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.hpp b/SDK/include/NDK/Widgets/TextAreaWidget.hpp index 94d984bd8..5c199e335 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.hpp +++ b/SDK/include/NDK/Widgets/TextAreaWidget.hpp @@ -40,6 +40,8 @@ namespace Ndk private: void RefreshCursor(); + void OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) override; + void OnKeyReleased(const Nz::WindowEvent::KeyEvent& key) override; void OnMouseEnter() override; void OnMouseButtonPress(int /*x*/, int /*y*/, Nz::Mouse::Button button) override; void OnMouseMoved(int x, int y, int deltaX, int deltaY) override; diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NDK/Widgets/TextAreaWidget.cpp index 747d57884..52190b250 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/TextAreaWidget.cpp @@ -111,6 +111,33 @@ namespace Ndk m_cursorEntity->GetComponent().SetPosition(position, lineInfo.bounds.y); } + void TextAreaWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) + { + switch (key.code) + { + case Nz::Keyboard::Left: + if (m_cursorPosition > 0) + m_cursorPosition--; + + RefreshCursor(); + break; + + case Nz::Keyboard::Right: + { + std::size_t glyphCount = m_drawer.GetGlyphCount(); + if (m_cursorPosition < glyphCount) + m_cursorPosition++; + + RefreshCursor(); + break; + } + } + } + + void TextAreaWidget::OnKeyReleased(const Nz::WindowEvent::KeyEvent& key) + { + } + void TextAreaWidget::OnMouseEnter() { m_cursorEntity->Enable(true);