Hi Antoine

One useful technique for finding out what the Silica components are doing (and how you may need to modify your code, or to prove a bug), is to create a private clone of the "problem" component in your project.

In your case it is ContextMenu, which on my development host lives in

/Users/christopherlamb/SailfishOSAlpha5/mersdk/targets/SailfishOS-i486-x86/usr/lib/qt5/qml/Sailfish/Silica/ContextMenu.qml

Copy that file into your project as AntContextMenu.qml, and in your code use AntContextMenu rather than ContextMenu.

You will also need to clone the private folder + contents to your project (without renaming).

Once you have done that, you can then add console.log statements in AntContextMenu.qml in appropriate places, make "what if .." changes, and generally play around in the guts of the Silica code. You can easily swap back and forth between your debug / hack version and the standard.

Of course this should only temporary while your are figuring out what is wrong. Once you have a solution you should revert to the standard component.

Chris


Zitat von Tigre-Bleu <de...@tigre-bleu.net>:

Hi,

I try to dynamically populate a ContextMenu but either I ran into a bug in the Silica Component or there is something I'm doing wrong.

Here is an example of simplified code showing the problem:

        ComboBox {
            width: parent.width
            label: "Menu"

            menu: ContextMenu {
                id: menu
                MenuItem { text: "Static 1" }
                MenuItem { text: "Static 2" }
            }

            Component {
                id: menuItemComp
                MenuItem {}
            }

            Component.onCompleted: {
                console.debug("Populating menu")
                for (var i=0; i< 4 ; i++){
var newMenuItem = menuItemComp.createObject(menu, {"text" : "Dynamic" + i})
                }
            }
        }

And in attachment is the result in the emulator.

We see that Static entries are correctly displayed, but dynamic ones are all superposed.

What is wrong?

Thanks,

Antoine



_______________________________________________
SailfishOS.org Devel mailing list

Reply via email to