SDK/TextAreaWidget: Add multiline option
This commit is contained in:
parent
7dc600fb34
commit
e66e0dfdce
|
|
@ -30,12 +30,15 @@ namespace Ndk
|
|||
|
||||
//virtual TextAreaWidget* Clone() const = 0;
|
||||
|
||||
inline void EnableMultiline(bool enable = true);
|
||||
|
||||
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 bool IsMultilineEnabled() const;
|
||||
inline bool IsReadOnly() const;
|
||||
|
||||
inline void MoveCursor(int offset);
|
||||
|
|
@ -68,6 +71,7 @@ namespace Ndk
|
|||
Nz::SpriteRef m_cursorSprite;
|
||||
Nz::TextSpriteRef m_textSprite;
|
||||
std::size_t m_cursorPosition;
|
||||
bool m_multiLineEnabled;
|
||||
bool m_readOnly;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,11 @@ namespace Ndk
|
|||
RefreshCursor();
|
||||
}
|
||||
|
||||
inline void TextAreaWidget::EnableMultiline(bool enable)
|
||||
{
|
||||
m_multiLineEnabled = enable;
|
||||
}
|
||||
|
||||
inline std::size_t TextAreaWidget::GetCursorPosition() const
|
||||
{
|
||||
return m_cursorPosition;
|
||||
|
|
@ -30,6 +35,11 @@ namespace Ndk
|
|||
return m_drawer.GetText();
|
||||
}
|
||||
|
||||
inline bool Ndk::TextAreaWidget::IsMultilineEnabled() const
|
||||
{
|
||||
return m_multiLineEnabled;
|
||||
}
|
||||
|
||||
inline bool TextAreaWidget::IsReadOnly() const
|
||||
{
|
||||
return m_readOnly;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ namespace Ndk
|
|||
TextAreaWidget::TextAreaWidget(BaseWidget* parent) :
|
||||
BaseWidget(parent),
|
||||
m_cursorPosition(0U),
|
||||
m_multiLineEnabled(false),
|
||||
m_readOnly(false)
|
||||
{
|
||||
m_cursorSprite = Nz::Sprite::New();
|
||||
|
|
@ -174,7 +175,7 @@ namespace Ndk
|
|||
{
|
||||
GrabKeyboard();
|
||||
|
||||
SetCursorPosition(GetHoveredGlyph(x, y));
|
||||
SetCursorPosition(GetHoveredGlyph(float(x), float(y)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -212,6 +213,9 @@ namespace Ndk
|
|||
|
||||
case '\r':
|
||||
case '\n':
|
||||
if (!m_multiLineEnabled)
|
||||
break;
|
||||
|
||||
Write(Nz::String('\n'));
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue