[SailfishDevel] Dynamically populate a ContextMenu
christopher.lamb at thurweb.ch
christopher.lamb at thurweb.ch
Sat Nov 23 14:42:01 UTC 2013
Hi Antoine
I had a quick play around, and a peak back in my old code.
Just changing the menu height does not change anything.
I also tried a version of your code with just dynamic menuItems. The
menu did not drop, it just flashes.
The problem I was fighting with some months ago (and did my best to
try and forget for a while as it was such a nightmare) was slightly
different. I had a set of ListViews, loaded from an SQLite DB, the
delegates of which expanded to show a contextMenu with static
menuItems. The problem was getting the ListViews to resize (and shift
the other contextMenus on the page) as the contextMenu opened and
closed.
Sorry not much help yet ...
Chris
Zitat von christopher.lamb at thurweb.ch:
> Hi Antoine
>
> I think I had similar problems some months ago.
>
> If I remember correctly, I had to explicitly resize the menu height
> after adding items to it.
>
> I will see if I can find the old code, and have a dig around in it ...
>
> Chris
>
> Zitat von Tigre-Bleu <devel at 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
>
More information about the Devel
mailing list