Sdk/Canvas: Add basic keyboard handler
This commit is contained in:
@@ -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)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user