Skip to content

scrollToWidget called continually #55

Description

@edherbert

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions