Sdk/TextAreaWidget: Add signals (allowing for controlling the cursor/keys)

This commit is contained in:
Lynix
2017-01-18 23:38:29 +01:00
parent 5d39d60f94
commit ec795269ad
3 changed files with 65 additions and 2 deletions

View File

@@ -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;

View File

@@ -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)