SDK/TextAreaWidget: Add cursor shifting by left and right arrows
This commit is contained in:
parent
d28dab2e36
commit
6c03803c5e
|
|
@ -40,6 +40,8 @@ namespace Ndk
|
|||
private:
|
||||
void RefreshCursor();
|
||||
|
||||
void OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) override;
|
||||
void OnKeyReleased(const Nz::WindowEvent::KeyEvent& key) override;
|
||||
void OnMouseEnter() override;
|
||||
void OnMouseButtonPress(int /*x*/, int /*y*/, Nz::Mouse::Button button) override;
|
||||
void OnMouseMoved(int x, int y, int deltaX, int deltaY) override;
|
||||
|
|
|
|||
|
|
@ -111,6 +111,33 @@ namespace Ndk
|
|||
m_cursorEntity->GetComponent<Ndk::NodeComponent>().SetPosition(position, lineInfo.bounds.y);
|
||||
}
|
||||
|
||||
void TextAreaWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key)
|
||||
{
|
||||
switch (key.code)
|
||||
{
|
||||
case Nz::Keyboard::Left:
|
||||
if (m_cursorPosition > 0)
|
||||
m_cursorPosition--;
|
||||
|
||||
RefreshCursor();
|
||||
break;
|
||||
|
||||
case Nz::Keyboard::Right:
|
||||
{
|
||||
std::size_t glyphCount = m_drawer.GetGlyphCount();
|
||||
if (m_cursorPosition < glyphCount)
|
||||
m_cursorPosition++;
|
||||
|
||||
RefreshCursor();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TextAreaWidget::OnKeyReleased(const Nz::WindowEvent::KeyEvent& key)
|
||||
{
|
||||
}
|
||||
|
||||
void TextAreaWidget::OnMouseEnter()
|
||||
{
|
||||
m_cursorEntity->Enable(true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue