From 3cff3fbadccf0fa9c0f100e99b2453deed0dfdf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Leclercq?= Date: Thu, 23 Nov 2017 13:24:13 +0100 Subject: [PATCH] Sdk/TextAreaWidget: Fix cursor showing up on readonly text area --- SDK/include/NDK/Widgets/TextAreaWidget.inl | 3 +-- SDK/src/NDK/Widgets/TextAreaWidget.cpp | 6 +++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/SDK/include/NDK/Widgets/TextAreaWidget.inl b/SDK/include/NDK/Widgets/TextAreaWidget.inl index 29b7cff98..35e7c67ee 100644 --- a/SDK/include/NDK/Widgets/TextAreaWidget.inl +++ b/SDK/include/NDK/Widgets/TextAreaWidget.inl @@ -170,8 +170,7 @@ namespace Ndk inline void TextAreaWidget::SetReadOnly(bool readOnly) { m_readOnly = readOnly; - - m_cursorEntity->Enable(!m_readOnly); + m_cursorEntity->Enable(!m_readOnly && HasFocus()); } inline void TextAreaWidget::SetText(const Nz::String& text) diff --git a/SDK/src/NDK/Widgets/TextAreaWidget.cpp b/SDK/src/NDK/Widgets/TextAreaWidget.cpp index 19071cac2..52a879b14 100644 --- a/SDK/src/NDK/Widgets/TextAreaWidget.cpp +++ b/SDK/src/NDK/Widgets/TextAreaWidget.cpp @@ -141,7 +141,8 @@ namespace Ndk void TextAreaWidget::OnFocusReceived() { - m_cursorEntity->Enable(true); + if (!m_readOnly) + m_cursorEntity->Enable(true); } void TextAreaWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) @@ -289,6 +290,9 @@ namespace Ndk void TextAreaWidget::RefreshCursor() { + if (m_readOnly) + return; + const auto& lineInfo = m_drawer.GetLine(m_cursorPosition.y); std::size_t cursorGlyph = GetGlyphIndex(m_cursorPosition);