Sdk/TextAreaWidget: Show cursor as long as focus is active
This commit is contained in:
parent
f136530a74
commit
0487b282d7
|
|
@ -23,6 +23,7 @@ Nazara Development Kit:
|
||||||
- Fixed minor issues relative to TextAreaWidget cursor handling
|
- Fixed minor issues relative to TextAreaWidget cursor handling
|
||||||
- ⚠️ Renamed BaseWidget::GrabKeyboard method to SetFocus
|
- ⚠️ Renamed BaseWidget::GrabKeyboard method to SetFocus
|
||||||
- Added BaseWidget::ClearFocus method and OnFocus[Lost|Received] virtual methods
|
- Added BaseWidget::ClearFocus method and OnFocus[Lost|Received] virtual methods
|
||||||
|
- TextAreaWidget will now show a cursor as long as it has focus
|
||||||
|
|
||||||
# 0.4:
|
# 0.4:
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -73,12 +73,12 @@ namespace Ndk
|
||||||
private:
|
private:
|
||||||
void Layout() override;
|
void Layout() override;
|
||||||
|
|
||||||
|
void OnFocusLost() override;
|
||||||
|
void OnFocusReceived() override;
|
||||||
void OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) override;
|
void OnKeyPressed(const Nz::WindowEvent::KeyEvent& key) override;
|
||||||
void OnKeyReleased(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 OnMouseButtonPress(int /*x*/, int /*y*/, Nz::Mouse::Button button) override;
|
||||||
void OnMouseMoved(int x, int y, int deltaX, int deltaY) override;
|
void OnMouseMoved(int x, int y, int deltaX, int deltaY) override;
|
||||||
void OnMouseExit() override;
|
|
||||||
void OnTextEntered(char32_t character, bool repeated) override;
|
void OnTextEntered(char32_t character, bool repeated) override;
|
||||||
|
|
||||||
void RefreshCursor();
|
void RefreshCursor();
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,16 @@ namespace Ndk
|
||||||
RefreshCursor();
|
RefreshCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextAreaWidget::OnFocusLost()
|
||||||
|
{
|
||||||
|
m_cursorEntity->Enable(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TextAreaWidget::OnFocusReceived()
|
||||||
|
{
|
||||||
|
m_cursorEntity->Enable(true);
|
||||||
|
}
|
||||||
|
|
||||||
void TextAreaWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key)
|
void TextAreaWidget::OnKeyPressed(const Nz::WindowEvent::KeyEvent& key)
|
||||||
{
|
{
|
||||||
switch (key.code)
|
switch (key.code)
|
||||||
|
|
@ -214,16 +224,11 @@ namespace Ndk
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextAreaWidget::OnMouseEnter()
|
|
||||||
{
|
|
||||||
m_cursorEntity->Enable(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextAreaWidget::OnMouseButtonPress(int x, int y, Nz::Mouse::Button button)
|
void TextAreaWidget::OnMouseButtonPress(int x, int y, Nz::Mouse::Button button)
|
||||||
{
|
{
|
||||||
if (button == Nz::Mouse::Left)
|
if (button == Nz::Mouse::Left)
|
||||||
{
|
{
|
||||||
GrabKeyboard();
|
SetFocus();
|
||||||
|
|
||||||
SetCursorPosition(GetHoveredGlyph(float(x), float(y)));
|
SetCursorPosition(GetHoveredGlyph(float(x), float(y)));
|
||||||
}
|
}
|
||||||
|
|
@ -231,11 +236,10 @@ namespace Ndk
|
||||||
|
|
||||||
void TextAreaWidget::OnMouseMoved(int x, int y, int /*deltaX*/, int /*deltaY*/)
|
void TextAreaWidget::OnMouseMoved(int x, int y, int /*deltaX*/, int /*deltaY*/)
|
||||||
{
|
{
|
||||||
}
|
if (m_isMouseButtonDown)
|
||||||
|
|
||||||
void TextAreaWidget::OnMouseExit()
|
|
||||||
{
|
{
|
||||||
m_cursorEntity->Enable(false);
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextAreaWidget::OnTextEntered(char32_t character, bool /*repeated*/)
|
void TextAreaWidget::OnTextEntered(char32_t character, bool /*repeated*/)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue