Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
naomipunkclan
Posts: 26
Registered: ‎04-25-2010
My Device: none

Access ScrollView viewableArea from javascript

hi,

 

According to the API reference a ScrollView has a viewableArea property of type QRectF[read-only]

 

Also signal :

void viewableAreaChanged (const QRectF &viewableArea, floatcontentScale )

 I can't seem to access the information in there. I have tried to explore as follows:

 

                onViewableAreaChanged: {
                    var propy;
                   var objLog = "viewable area change:\n\n";
         
                     for (propy in viewableArea) {
                      objLog+=propy + ':' + viewableArea[propy] + '; ';   
                     };
                          
                             
                 console.log(objLog);
}

 But no properties to be found. The QRectF type only has accessor functions. So trying the obvious:

 

                 console.log(viewableArea.left());

 ... yields:

 

 TypeError: Result of expression 'viewableArea.left' [undefined] is not a function.

 So, I am stuck on how to get these values out of the viewableArea object. I am guessing I need to use

qmlRegisterType()

 as per the docs at https://developer.blackberry.com/cascades/documentation/dev/integrating_cpp_qml/index.html

 

I was expecting to need that for custom components rather than the standard cascades ones. Any one have any guidance on this?

 

thanks

 

Developer
oliver_kranz
Posts: 216
Registered: ‎09-18-2009
My Device: Z10

Re: Access ScrollView viewableArea from javascript

To get the dimensions and position of the ScrollView you can use the LayoutUpdateHandler.

 

ScrollView {
    property int width: scrollViewHandler.layoutFrame.width
    property int height: scrollViewHandler.layoutFrame.height
    property int x: scrollViewHandler.layoutFrame.x
    property int y: scrollViewHandler.layoutFrame.y
    attachedObjects: [
        LayoutUpdateHandler {
            id: scrollViewHandler
        }
    ]
}