[SailfishDevel] ContextMenu used with multiple Views on one Page

christopher.lamb at thurweb.ch christopher.lamb at thurweb.ch
Sun Jun 23 14:26:18 UTC 2013


Hi all

the attachment MC_MainPage4.jp2 shows the expected behaviour.

The culprit seems to be the following ProperytChanges in the ContextMenu.qml

         PropertyChanges {
             target: _flickable
             contentY:  
Math.max(contextMenu.mapToItem(_flickable.contentItem, 0,  
contextMenu.childrenRect.height).y - _flickable.height,  
_flickable.contentY)
             interactive: false
             explicit: true
         }

If I comment this out, then the menu opens as I expect, below the  
chosen item, and not at the top of the view.

Note: to test this I created a clone of the standard Silica version of  
this component, and referred to the clone in my project.

Chris

Zitat von christopher.lamb at thurweb.ch:

> Hi All
>
> I am struggling to get a Silica ContextNenu working from a view.
>
> I have taken the ComponentsGallery MenuPage as a reference example.   
> When an entry on the view is PressAndHold(ed) a ContextMenu "drops   
> down" below the selected item.
>
> In most cases this causes the items below those selected to slide   
> down. Towards the bottom of the screen it causes items above to  
> slide  up (so there is room to paint the ContextMenu).
>
> In my app I have a column of 4 Views in a parent child relationship.  
>  Clicking on an item in View 1 causes Views 2, 3, and 4 to  
> repopulate.  Clicking on an item in View 2 causes Views 3 and 4 to  
> repopulate. (See  MC_MainPage1.jp2).
>
> When a item is clicked, I "expand* the delegate and the view holding  
>  the item to create space for the ContextMenu (which may be taller  
> than  the View in its normal state). Lower Views slide down  
> accordingly.  (See MC_MainPage2.jp2). So far so good.
>
> However when a I add the ContextMenu, things go a little haywire, as  
>  can be seen in MC_MainPage3.jp2. Rather than sliding lower  
> ListItems  down, the ContextMenu slides higher ListIems up, and sits  
> itself at  the top of the View / screen.
>
> Any ideas of what is going on?
>
> I suspect that my use case may be a little too exotic for the  
> standard  ContextMenu: I am on the brink of implementing my own  
> custom  equivalent, but thought I would seek the wise council of  
> others before  doing so.
>
> My code can be found here:
> https://github.com/sailfishapps/landed/tree/master/landedsettings21/qml/landedsettings21
>
> The .qmls related to this issue are:
> MainPage
> https://github.com/sailfishapps/landed/blob/master/landedsettings21/qml/landedsettings21/MainPage.qml
> LandedMVD (my generic Model View Delegate Control, used 4 times by MainPage)
> https://github.com/sailfishapps/landed/blob/master/landedsettings21/qml/landedsettings21/LandedMVD.qml
> ViewDelegate (the delegate used by MainPage/LandedMVD)
> https://github.com/sailfishapps/landed/blob/master/landedsettings21/qml/landedsettings21/ViewDelegate.qml
>
> Chris
>
>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: MC_MainPage4.jp2
Type: image/jp2
Size: 96381 bytes
Desc: not available
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20130623/30b64877/attachment.bin>


More information about the Devel mailing list