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

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

Access ScrollView viewableArea from javascript



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] + '; ';   

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



 ... 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


 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?




Posts: 217
Registered: ‎09-18-2009
My Device: Z10
My Carrier: O2

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