I discovered this issue when trying to create a scrollable window which contained only non keyboard focusable widgets (labels). In this case, ColibriManager.cpp:1531 resets m_keyboardFocusedPair.widget to 0 each frame, and then the block below beginning at 1540 notices that the widget is missing so tries to query the default widget from the window and set it. If the widget returned happens to be non keyboard navigable, then it gets setup, scrolled to, but the next frame it is reset again and the cycle continues, meaning scrollToWidget is constantly called each frame. For me this effectively disabled scrolling on this window as any time you scroll, it scrolled back to the top automatically to the default widget.
My solution to this was to add a check for keyboard focusability
diff --git a/src/ColibriGui/ColibriManager.cpp b/src/ColibriGui/ColibriManager.cpp
index 64a5e69..7d44887 100644
--- a/src/ColibriGui/ColibriManager.cpp
+++ b/src/ColibriGui/ColibriManager.cpp
@@ -1538,7 +1538,7 @@ namespace Colibri
if( m_keyboardFocusedPair.window && !m_keyboardFocusedPair.widget )
{
m_keyboardFocusedPair.widget = m_keyboardFocusedPair.window->getDefaultWidget();
- if( m_keyboardFocusedPair.widget )
+ if( m_keyboardFocusedPair.widget && m_keyboardFocusedPair.widget->isKeyboardNavigable() )
{
m_keyboardFocusedPair.widget->setState( States::HighlightedButton );
callActionListeners( m_keyboardFocusedPair.widget, Action::Highlighted );
However on closer inspection I see that this doesn't break the cycle and the getDefaultWidget function would be called each frame, which is just a pointless for loop.
I discovered this issue when trying to create a scrollable window which contained only non keyboard focusable widgets (labels). In this case,
ColibriManager.cpp:1531resetsm_keyboardFocusedPair.widgetto 0 each frame, and then the block below beginning at1540notices that the widget is missing so tries to query the default widget from the window and set it. If the widget returned happens to be non keyboard navigable, then it gets setup, scrolled to, but the next frame it is reset again and the cycle continues, meaningscrollToWidgetis constantly called each frame. For me this effectively disabled scrolling on this window as any time you scroll, it scrolled back to the top automatically to the default widget.My solution to this was to add a check for keyboard focusability
However on closer inspection I see that this doesn't break the cycle and the getDefaultWidget function would be called each frame, which is just a pointless for loop.