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
Posts: 153
Registered: ‎04-12-2010
My Device: Storm

horizontalscrollview detect x change

[ Edited ]

how to detect the x change??? the onViewableAreaChanged: gets triggered when I scroll sideways but how do get the x value???? the viewableArea.left  doesn't seem to respond??? or how do u make sense of the blurry documentation the signal is supposed to deliver the viewableArea  rectangle

 

Or better yet I have 3 views I added how do I detect when one view is in the viweable port???

 

 

I have also trid adding like below  but it also it always returns 0 no matter how  much I shift

 

attachedObjects: [ // to get te x position of the scrollview
LayoutUpdateHandler {
id: scrollViewHandler
}

 

 

  Thanks in advance

 

Developer
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10

Re: horizontalscrollview detect x change

bool firstChanging = true

 

When you recieve the signal onViewableAreaChanging(const QRectF &viewableArea, float contentScale):

 

if (firstChanging)

double left = viewableArea.left()

firstChanging = false

 

This will save the inital x value ONCE. Then, onViewableAreaChanged(const QRectF &viewableArea, float contentScale):

 

double x = viewableArea.left() - left

firstChanging = true

 

That should give you the total movement in x. If not, come back here with your results (remember, this is pseudocode).

 

----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!
New Developer
Posts: 153
Registered: ‎04-12-2010
My Device: Storm

Re: horizontalscrollview detect x change

Thanks for the hint, that seems like it would return the delta once it works, but the small detail is getting it to work

 

I'm trying this on theQML side, I put a toast box to print the viewableArea.left() on the onViewableAreaChanged and the msg never pops if I just pop a hello msg without calling the viewableAre.left() I do get the pop msg  which leads me to believe it is failing as it has on some other similar cases, using the Momentics x.x.x.1020 cannot debug the QML other than putting popups. Do I need to do some conversion??? everything is a var in QML as I think is just like JavaScript at that stage.

 

Adding/deleting the onViewableAreaChanging makes no difference.

 

Should I call a C++ function instead and then send a signal back to QML??? In other situations like this that was the only way to get around this.

 

 

 

 

Developer
Posts: 133
Registered: ‎05-10-2013
My Device: Blackberry Z10

Re: horizontalscrollview detect x change

If you think diong it through C++ would be simpler then debugging your problem, then by all means go for it.

 

Now, instead of having a pop-up, you could have it change the text property of a Label. That way you'll get a visual queue and will be able to see if .left() is functionnal or not. And I don't nkow what you mean by everything being a var; you have to define the type of every variable in QML...

----------------------------------------
Remember to mark the thread as solved at the post that solved your problem, and if you like a post, like it!