SDK/TextAreaWidget: Expose cursor
This commit is contained in:
@@ -30,13 +30,17 @@ namespace Ndk
|
||||
|
||||
//virtual TextAreaWidget* Clone() const = 0;
|
||||
|
||||
inline std::size_t GetCursorPosition() const;
|
||||
inline std::size_t GetLineCount() const;
|
||||
inline const Nz::String& GetText() const;
|
||||
|
||||
std::size_t GetHoveredGlyph(float x, float y) const;
|
||||
|
||||
inline void MoveCursor(int offset);
|
||||
|
||||
void ResizeToContent() override;
|
||||
|
||||
inline void SetCursorPosition(std::size_t cursorPosition);
|
||||
void SetText(const Nz::String& text);
|
||||
|
||||
void Write(const Nz::String& text);
|
||||
|
||||
@@ -15,6 +15,11 @@ namespace Ndk
|
||||
RefreshCursor();
|
||||
}
|
||||
|
||||
inline std::size_t TextAreaWidget::GetCursorPosition() const
|
||||
{
|
||||
return m_cursorPosition;
|
||||
}
|
||||
|
||||
inline std::size_t TextAreaWidget::GetLineCount() const
|
||||
{
|
||||
return m_drawer.GetLineCount();
|
||||
@@ -24,4 +29,25 @@ namespace Ndk
|
||||
{
|
||||
return m_drawer.GetText();
|
||||
}
|
||||
|
||||
inline void TextAreaWidget::MoveCursor(int offset)
|
||||
{
|
||||
if (offset >= 0)
|
||||
SetCursorPosition(m_cursorPosition += static_cast<std::size_t>(offset));
|
||||
else
|
||||
{
|
||||
std::size_t nOffset = static_cast<std::size_t>(-offset);
|
||||
if (nOffset >= m_cursorPosition)
|
||||
SetCursorPosition(0);
|
||||
else
|
||||
SetCursorPosition(m_cursorPosition - nOffset);
|
||||
}
|
||||
}
|
||||
|
||||
inline void TextAreaWidget::SetCursorPosition(std::size_t cursorPosition)
|
||||
{
|
||||
m_cursorPosition = std::min(cursorPosition, m_drawer.GetGlyphCount());
|
||||
|
||||
RefreshCursor();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user