Sdk/TextAreaWidget: Add signals (allowing for controlling the cursor/keys)
This commit is contained in:
@@ -56,6 +56,14 @@ namespace Ndk
|
||||
TextAreaWidget& operator=(const TextAreaWidget&) = delete;
|
||||
TextAreaWidget& operator=(TextAreaWidget&&) = default;
|
||||
|
||||
NazaraSignal(OnTextAreaCursorMove, const TextAreaWidget* /*textArea*/, std::size_t* /*newCursorPosition*/);
|
||||
NazaraSignal(OnTextAreaKeyBackspace, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyDown, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyLeft, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyReturn, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyRight, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
NazaraSignal(OnTextAreaKeyUp, const TextAreaWidget* /*textArea*/, bool* /*ignoreDefaultAction*/);
|
||||
|
||||
private:
|
||||
void Layout() override;
|
||||
|
||||
|
||||
@@ -66,6 +66,8 @@ namespace Ndk
|
||||
|
||||
inline void TextAreaWidget::SetCursorPosition(std::size_t cursorPosition)
|
||||
{
|
||||
OnTextAreaCursorMove(this, &cursorPosition);
|
||||
|
||||
m_cursorPosition = std::min(cursorPosition, m_drawer.GetGlyphCount());
|
||||
|
||||
RefreshCursor();
|
||||
@@ -83,6 +85,8 @@ namespace Ndk
|
||||
m_drawer.SetText(text);
|
||||
|
||||
m_textSprite->Update(m_drawer);
|
||||
|
||||
SetCursorPosition(m_cursorPosition); //< Refresh cursor position (prevent it from being outside of the text)
|
||||
}
|
||||
|
||||
inline void TextAreaWidget::SetTextColor(const Nz::Color& text)
|
||||
|
||||
Reference in New Issue
Block a user