[SailfishDevel] Context menu of a grid view

Marcin Mielniczuk marmistrzmar at gmail.com
Mon Nov 21 17:49:46 UTC 2016


Hi,

In my app I show the user a grid view. It's elements should be
interactive and its state can be modified.

I'd like to use a context menu for this. My current approach is

            SilicaGridView {
                id: diceView

                Layout.preferredWidth: parent.width
                Layout.fillHeight: true

                model: myModel

                cellWidth: width / gridDimension
                cellHeight: height / gridDimension

                delegate: BackgroundItem {

                    id: bgItem
                    width: diceView.cellWidth
                    height: diceView.cellHeight

                    /* contents */

                    ContextMenu {
                        id: contextMenu
                        parent: bgItem
                        anchors {
                            left: bgItem.left
                            right: bgItem.right
                            bottom: bgItem.bottom
                        }

                        RemorseItem {
                            id: remorse
                            wrapMode: Text.WordWrap
                            horizontalAlignment: Text.AlignHCenter
                        }

                        MenuItem {
                            text: qsTr("foo")
                        }

                        MenuItem {
                            text: qsTr("bar")
                        }
                    }

                    onPressAndHold: contextMenu.show(this)
                }

The problem is that with two elements, the context menu that overlaps
the delegate content, which makes the MenuItems illegible.

What is the recommended UX solution for this? Seems that ContextMenu
works out-of-the-box for SilicaListViews but not for SilicaGridViews.

-- 
Marcin




More information about the Devel mailing list