We have moved to a new Sailfish OS Forum. Please start new discussions there.
0

Using ContextMenu with TextSwitch in ListView

asked 2017-04-18 03:05:42 +0300

gabriel9 gravatar image

updated 2017-04-18 11:46:19 +0300

coderus gravatar image

So i have a simple ListView, and i if i use Label as delegate i can use ContextMenu with it. But when i try to use TextSwitch with ContextMenu, ContextMenu does not work. Click is reserved for TextSwitch toggle. I tried to check automaticCheck to false and it is not working.

So, it is possible to combine TextSwitch with ContextMenu?

All best

edit retag flag offensive close delete

1 Answer

Sort by » oldest newest most voted
1

answered 2017-04-18 10:06:44 +0300

coderus gravatar image

https://github.com/CODeRUS/powermenu2/blob/master/gui/qmls/pages/ConfigurationPage.qml#L184

edit flag offensive delete publish link more

Comments

Thanks for the link. I did not run the code, but as i see it you are using TextSwitch inside ContextMenu. I want to use TextSwitch inside ListView and when i hold on one of them(TextSwitch) i want to pop up ContextMenu for it.

gabriel9 ( 2017-04-18 11:30:54 +0300 )edit
1

import QtQuick 2.0 import Sailfish.Silica 1.0

Page {
    id: page

    SilicaListView {
        id: view
        anchors.fill: parent
        model: 20
        delegate: Component {
            ListItem {
                id: delegate
                contentHeight: Theme.itemSizeSmall
                menu: Component {
                    ContextMenu {
                        MenuItem {
                            text: "Menu for %1".arg(index)
                            onClicked: console.log(text)
                        }
                    }
                }
                TextSwitch {
                    anchors.verticalCenter: parent.verticalCenter
                    width: parent.width
                    text: "Switch for %1".arg(index)
                    onPressAndHold: delegate.showMenu()
                }
            }
        }
    }
}
coderus ( 2017-04-18 11:40:32 +0300 )edit

Works with onPressAndHold. Thanks.

gabriel9 ( 2017-04-20 13:11:56 +0300 )edit
Login/Signup to Answer

Question tools

Follow
1 follower

Stats

Asked: 2017-04-18 03:05:42 +0300

Seen: 169 times

Last updated: Apr 18 '17