mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 01:59:02 +08:00
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:
parent
8917762ed5
commit
0f9cfa0304
@ -19,6 +19,9 @@ Button {
|
||||
signal contextMenuRequested()
|
||||
signal showAllHiddenInheritedSettings(string category_id)
|
||||
signal focusReceived()
|
||||
signal setActiveFocusToNextSetting(bool forward)
|
||||
|
||||
property var focusItem: base
|
||||
|
||||
text: definition.label
|
||||
iconSource: UM.Theme.getIcon(definition.icon)
|
||||
@ -44,6 +47,15 @@ Button {
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onTabPressed:
|
||||
{
|
||||
base.setActiveFocusToNextSetting(true)
|
||||
}
|
||||
Keys.onBacktabPressed:
|
||||
{
|
||||
base.setActiveFocusToNextSetting(false)
|
||||
}
|
||||
|
||||
UM.SimpleButton
|
||||
{
|
||||
id: settingsButton
|
||||
|
@ -11,13 +11,13 @@ import UM 1.2 as UM
|
||||
SettingItem
|
||||
{
|
||||
id: base
|
||||
property var focusItem: control
|
||||
|
||||
contents: MouseArea
|
||||
{
|
||||
id: control
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
activeFocusOnTab: true
|
||||
|
||||
property bool checked:
|
||||
{
|
||||
@ -62,6 +62,15 @@ SettingItem
|
||||
propertyProvider.setPropertyValue("value", !checked);
|
||||
}
|
||||
|
||||
Keys.onTabPressed:
|
||||
{
|
||||
base.setActiveFocusToNextSetting(true)
|
||||
}
|
||||
Keys.onBacktabPressed:
|
||||
{
|
||||
base.setActiveFocusToNextSetting(false)
|
||||
}
|
||||
|
||||
onActiveFocusChanged:
|
||||
{
|
||||
if(activeFocus)
|
||||
|
@ -10,6 +10,7 @@ import UM 1.1 as UM
|
||||
SettingItem
|
||||
{
|
||||
id: base
|
||||
property var focusItem: control
|
||||
|
||||
contents: ComboBox
|
||||
{
|
||||
@ -108,6 +109,15 @@ SettingItem
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onTabPressed:
|
||||
{
|
||||
base.setActiveFocusToNextSetting(true)
|
||||
}
|
||||
Keys.onBacktabPressed:
|
||||
{
|
||||
base.setActiveFocusToNextSetting(false)
|
||||
}
|
||||
|
||||
Binding
|
||||
{
|
||||
target: control
|
||||
|
@ -11,6 +11,7 @@ import Cura 1.0 as Cura
|
||||
SettingItem
|
||||
{
|
||||
id: base
|
||||
property var focusItem: control
|
||||
|
||||
contents: ComboBox
|
||||
{
|
||||
@ -35,6 +36,15 @@ SettingItem
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onTabPressed:
|
||||
{
|
||||
base.setActiveFocusToNextSetting(true)
|
||||
}
|
||||
Keys.onBacktabPressed:
|
||||
{
|
||||
base.setActiveFocusToNextSetting(false)
|
||||
}
|
||||
|
||||
currentIndex: propertyProvider.properties.value
|
||||
|
||||
MouseArea
|
||||
|
@ -33,6 +33,7 @@ Item {
|
||||
property var stackLevel: stackLevels[0]
|
||||
|
||||
signal focusReceived()
|
||||
signal setActiveFocusToNextSetting(bool forward)
|
||||
signal contextMenuRequested()
|
||||
signal showTooltip(string text)
|
||||
signal hideTooltip()
|
||||
|
@ -11,6 +11,7 @@ import Cura 1.0 as Cura
|
||||
SettingItem
|
||||
{
|
||||
id: base
|
||||
property var focusItem: control
|
||||
|
||||
contents: ComboBox
|
||||
{
|
||||
@ -39,6 +40,15 @@ SettingItem
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onTabPressed:
|
||||
{
|
||||
base.setActiveFocusToNextSetting(true)
|
||||
}
|
||||
Keys.onBacktabPressed:
|
||||
{
|
||||
base.setActiveFocusToNextSetting(false)
|
||||
}
|
||||
|
||||
Binding
|
||||
{
|
||||
target: control
|
||||
|
@ -9,6 +9,7 @@ import UM 1.1 as UM
|
||||
SettingItem
|
||||
{
|
||||
id: base
|
||||
property var focusItem: input
|
||||
|
||||
contents: Rectangle
|
||||
{
|
||||
@ -93,7 +94,15 @@ SettingItem
|
||||
right: parent.right
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
activeFocusOnTab: true
|
||||
|
||||
Keys.onTabPressed:
|
||||
{
|
||||
base.setActiveFocusToNextSetting(true)
|
||||
}
|
||||
Keys.onBacktabPressed:
|
||||
{
|
||||
base.setActiveFocusToNextSetting(false)
|
||||
}
|
||||
|
||||
Keys.onReleased:
|
||||
{
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user