Sdk/Canvas: Add basic keyboard handler

This commit is contained in:
Lynix
2016-10-28 17:46:02 +02:00
parent 38da351e9b
commit 7df732b927
5 changed files with 36 additions and 1 deletions

View File

@@ -71,6 +71,11 @@ namespace Ndk
m_entities.erase(it);
}
void BaseWidget::GrabKeyboard()
{
m_canvas->SetKeyboardOwner(this);
}
void BaseWidget::Layout()
{
if (m_canvas)
@@ -112,4 +117,8 @@ namespace Ndk
void BaseWidget::OnMouseExit()
{
}
void BaseWidget::OnTextEntered(char32_t character, bool repeated)
{
}
}

View File

@@ -57,6 +57,9 @@ namespace Ndk
if (m_hoveredWidget == &entry)
m_hoveredWidget = nullptr;
if (m_keyboardOwner == entry.widget)
m_keyboardOwner = nullptr;
entry = std::move(lastEntry);
entry.widget->UpdateCanvasIndex(index);
m_widgetBoxes.pop_back();
@@ -136,4 +139,10 @@ namespace Ndk
m_hoveredWidget = nullptr;
}
}
void Canvas::OnTextEntered(const Nz::EventHandler* eventHandler, const Nz::WindowEvent::TextEvent& event)
{
if (m_keyboardOwner)
m_keyboardOwner->OnTextEntered(event.character, event.repeated);
}
}