Fix tab order after expanding categories or using search

This reimplements the behavior of pressing tab/backtab to force the correct order of items in the listview.
This commit is contained in:
fieldOfView 2017-06-26 14:35:37 +02:00
parent 8917762ed5
commit 0f9cfa0304
8 changed files with 93 additions and 2 deletions

View file

@ -168,6 +168,8 @@ Item
onVisibilityChanged: Cura.SettingInheritanceManager.forceUpdate()
}
property var indexWithFocus: -1
delegate: Loader
{
id: delegate
@ -300,11 +302,39 @@ Item
}
onFocusReceived:
{
contents.indexWithFocus = index;
animateContentY.from = contents.contentY;
contents.positionViewAtIndex(index, ListView.Contain);
animateContentY.to = contents.contentY;
animateContentY.running = true;
}
onSetActiveFocusToNextSetting:
{
if(forward == undefined || forward)
{
contents.currentIndex = contents.indexWithFocus + 1;
while(contents.currentItem && contents.currentItem.height <= 0)
{
contents.currentIndex++;
}
if(contents.currentItem)
{
contents.currentItem.item.focusItem.forceActiveFocus();
}
}
else
{
contents.currentIndex = contents.indexWithFocus - 1;
while(contents.currentItem && contents.currentItem.height <= 0)
{
contents.currentIndex--;
}
if(contents.currentItem)
{
contents.currentItem.item.focusItem.forceActiveFocus();
}
}
}
}
}