From 8bc31b60a1912c46c62dc0883565c83f807c8bc1 Mon Sep 17 00:00:00 2001 From: Cyril Anisimov Date: Sat, 14 Dec 2024 19:29:35 +0100 Subject: [PATCH] fix checked item in lists --- .../Controls2/ListViewWithRadioButtonType.qml | 40 ++++--------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/client/ui/qml/Controls2/ListViewWithRadioButtonType.qml b/client/ui/qml/Controls2/ListViewWithRadioButtonType.qml index 8409e964..da5561ca 100644 --- a/client/ui/qml/Controls2/ListViewWithRadioButtonType.qml +++ b/client/ui/qml/Controls2/ListViewWithRadioButtonType.qml @@ -20,7 +20,7 @@ ListView { property var clickedFunction - currentIndex: 0 + property int selectedIndex: 0 width: rootWidth height: root.contentItem.height @@ -29,45 +29,21 @@ ListView { 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 { id: buttonGroup } function triggerCurrentItem() { - var item = root.itemAtIndex(currentIndex) - var radioButton = item.children[0] - radioButton.clicked() + var item = root.itemAtIndex(selectedIndex) + item.selectable.clicked() } delegate: ColumnLayout { id: content + property alias selectable: radioButton + implicitWidth: rootWidth - // implicitHeight: content.implicitHeight RadioButton { id: radioButton @@ -156,10 +132,10 @@ ListView { } ButtonGroup.group: buttonGroup - checked: root.currentIndex === index + checked: root.selectedIndex === index onClicked: { - root.currentIndex = index + root.selectedIndex = index root.selectedText = name if (clickedFunction && typeof clickedFunction === "function") { clickedFunction() @@ -168,7 +144,7 @@ ListView { } Component.onCompleted: { - if (root.currentIndex === index) { + if (root.selectedIndex === index) { root.selectedText = name } }