fix checked item in lists
This commit is contained in:
parent
149c9d12d3
commit
8bc31b60a1
1 changed files with 8 additions and 32 deletions
|
|
@ -20,7 +20,7 @@ ListView {
|
||||||
|
|
||||||
property var clickedFunction
|
property var clickedFunction
|
||||||
|
|
||||||
currentIndex: 0
|
property int selectedIndex: 0
|
||||||
|
|
||||||
width: rootWidth
|
width: rootWidth
|
||||||
height: root.contentItem.height
|
height: root.contentItem.height
|
||||||
|
|
@ -29,45 +29,21 @@ ListView {
|
||||||
|
|
||||||
property bool isFocusable: true
|
property bool isFocusable: true
|
||||||
|
|
||||||
Keys.onTabPressed: {
|
|
||||||
FocusController.nextKeyTabItem()
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onBacktabPressed: {
|
|
||||||
FocusController.previousKeyTabItem()
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onUpPressed: {
|
|
||||||
FocusController.nextKeyUpItem()
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onDownPressed: {
|
|
||||||
FocusController.nextKeyDownItem()
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onLeftPressed: {
|
|
||||||
FocusController.nextKeyLeftItem()
|
|
||||||
}
|
|
||||||
|
|
||||||
Keys.onRightPressed: {
|
|
||||||
FocusController.nextKeyRightItem()
|
|
||||||
}
|
|
||||||
|
|
||||||
ButtonGroup {
|
ButtonGroup {
|
||||||
id: buttonGroup
|
id: buttonGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggerCurrentItem() {
|
function triggerCurrentItem() {
|
||||||
var item = root.itemAtIndex(currentIndex)
|
var item = root.itemAtIndex(selectedIndex)
|
||||||
var radioButton = item.children[0]
|
item.selectable.clicked()
|
||||||
radioButton.clicked()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delegate: ColumnLayout {
|
delegate: ColumnLayout {
|
||||||
id: content
|
id: content
|
||||||
|
|
||||||
|
property alias selectable: radioButton
|
||||||
|
|
||||||
implicitWidth: rootWidth
|
implicitWidth: rootWidth
|
||||||
// implicitHeight: content.implicitHeight
|
|
||||||
|
|
||||||
RadioButton {
|
RadioButton {
|
||||||
id: radioButton
|
id: radioButton
|
||||||
|
|
@ -156,10 +132,10 @@ ListView {
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonGroup.group: buttonGroup
|
ButtonGroup.group: buttonGroup
|
||||||
checked: root.currentIndex === index
|
checked: root.selectedIndex === index
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.currentIndex = index
|
root.selectedIndex = index
|
||||||
root.selectedText = name
|
root.selectedText = name
|
||||||
if (clickedFunction && typeof clickedFunction === "function") {
|
if (clickedFunction && typeof clickedFunction === "function") {
|
||||||
clickedFunction()
|
clickedFunction()
|
||||||
|
|
@ -168,7 +144,7 @@ ListView {
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (root.currentIndex === index) {
|
if (root.selectedIndex === index) {
|
||||||
root.selectedText = name
|
root.selectedText = name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue