diff --git a/include/Nazara/Widgets/Canvas.inl b/include/Nazara/Widgets/Canvas.inl index 8c9de3533..238500281 100644 --- a/include/Nazara/Widgets/Canvas.inl +++ b/include/Nazara/Widgets/Canvas.inl @@ -84,11 +84,13 @@ namespace Nz { if (m_keyboardOwner != canvasIndex) { - if (m_keyboardOwner != InvalidCanvasIndex) - m_widgetEntries[m_keyboardOwner].widget->OnFocusLost(); + std::size_t previousOwner = m_keyboardOwner; m_keyboardOwner = canvasIndex; + if (previousOwner != InvalidCanvasIndex) + m_widgetEntries[previousOwner].widget->OnFocusLost(); + if (m_keyboardOwner != InvalidCanvasIndex) m_widgetEntries[m_keyboardOwner].widget->OnFocusReceived(); }