← Back to team overview

ubuntu-phone team mailing list archive

Re: Positioning the screen to an element in Expandable

 

Alright, I've been ignoring it for awhile, meaning to get back to it.
But, whenever I open a page, I get a couple of warning messages, and
just noticed that these might be related:

        file:///home/s/Hacking/Dict-eo/qml/abel.qml:19:1: QML
        ExpandablesColumn: mapFromItem() given argument "undefined"
        which is neither null nor an Item
        file:///home/s/Hacking/Dict-eo/qml/abel.qml:8:1: QML Page:
        Binding loop detected for property "flickable"

Note, there is no use of the mapFromItem() in my code, so it's hitting
the warning somewhere internal to the SDK.

On mer, 2014-07-23 at 20:29 +0100, Sam Bull wrote:
> OK, there's no delegate, it's all hardcoded elements. To clarify, the
> expandable doesn't come into view if it's expanded as I display the
> page, it does however work when I later click an item to expand a
> section.
> 
> I'll put some of the code here as an example. The page is created and
> displayed with these two lines:
> 
>         pagestack.push(Qt.resolvedUrl("qml/" + file))
>         pagestack.currentPage.openSection(link.split("."))
> 
> Then, the beginning of the page being loaded, looks like this:
> 
>         Page {
>             id: resultsPage
>             anchors.fill: parent
>             visible: false
>             title: "a"
>         
>         function openSection(refLink) {
>             if (refLink.length > 1) {
>                 var expandable = eval(refLink[0] + "_" + refLink[1])
>                 // This doesn't move the screen to the element.
>                 expandable.expanded = true
>                 // This always prints 76 for any element.
>                 print(root.mapFromItem(expandable.parent, expandable.x, expandable.y).y)
>             }
>         }
>         
>         ListItem.ExpandablesColumn {  // ART
>             id: colu
>             anchors.fill: parent
>         
>                 ListItem.Expandable {  // DRV
>                         id: a1_0
>                         onClicked: expanded = true
>                         collapsedHeight: units.gu(6)
>                         collapseOnClick: true
>                         expandedHeight: drv_idm247665072.height + units.gu(1)
>                         
>                         ... and so on
> 
> On mer, 2014-07-23 at 19:26 +0200, Michael Zanetti wrote:
> > On Wednesday 23 July 2014 17:57:13 Sam Bull wrote:
> > > I would like to position the screen so that it scrolls to a specific
> > > element after opening a page.
> > > 
> > > First, I'd like to be able to make sure an Expandable is in view upon
> > > expanding it (though this could be considered a bug of ExpandablesColumn
> > > that it doesn't do this automatically).
> > 
> > Hmm, that should work. I just tried the example from the doc and it expands 
> > fine.
> > 
> > > 
> > > But, then I'd also like to be able to bring certain sub-items to the top
> > > of the display.
> > > 
> > > Unfortunately, reading the .y attribute always gives 0 for all these
> > > elements. Likewise, trying to get the global position with something
> > > like:
> > >         root.mapFromItem(elem.parent, elem.x, elem.y).y
> > > always returns 76.
> > 
> > delegate.mapToItem(ListView.view)
> > 
> > > 
> > > I don't know if maybe the elements haven't finished loading or
> > > something. If that is the case, is there any way to connect to the
> > > elements positions when they are changed? I've tried things like
> > > elem.onYChanged = function() ... but it's not working.
> > 
> > I think the item's y should also work. Maybe its a problem with your delegate 
> > items?
> > 
> > Br,
> > Michael
> > 
> 
> 


Attachment: signature.asc
Description: This is a digitally signed message part


References