SDK/TextAreaWidget: Add ReadOnly option

This commit is contained in:
Lynix
2016-12-06 16:33:55 +01:00
parent c781f7cb45
commit 7dc600fb34
3 changed files with 22 additions and 2 deletions

View File

@@ -36,11 +36,14 @@ namespace Ndk
std::size_t GetHoveredGlyph(float x, float y) const;
inline bool IsReadOnly() const;
inline void MoveCursor(int offset);
void ResizeToContent() override;
inline void SetCursorPosition(std::size_t cursorPosition);
inline void SetReadOnly(bool readOnly = true);
void SetText(const Nz::String& text);
void Write(const Nz::String& text);
@@ -65,6 +68,7 @@ namespace Ndk
Nz::SpriteRef m_cursorSprite;
Nz::TextSpriteRef m_textSprite;
std::size_t m_cursorPosition;
bool m_readOnly;
};
}

View File

@@ -30,6 +30,11 @@ namespace Ndk
return m_drawer.GetText();
}
inline bool TextAreaWidget::IsReadOnly() const
{
return m_readOnly;
}
inline void TextAreaWidget::MoveCursor(int offset)
{
if (offset >= 0)
@@ -50,4 +55,11 @@ namespace Ndk
RefreshCursor();
}
inline void TextAreaWidget::SetReadOnly(bool readOnly)
{
m_readOnly = readOnly;
m_cursorEntity->Enable(!m_readOnly);
}
}