From 809dc7e0a7306c12545da7a5c59c1cf82823cc99 Mon Sep 17 00:00:00 2001 From: SirLynix Date: Wed, 23 Aug 2023 17:56:53 +0200 Subject: [PATCH] Widgets/Canvas: Fix OnFocusLost being called before removing focus --- include/Nazara/Widgets/Canvas.inl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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(); }