02-14-2013 08:03 AM
Hello,
I'm fairly new to Cascades development, but have some ideas I want to implement.
I'm struggling for some days trying to scroll a textarea semi-automatically.
I have a ScrollView with a textarea inside.
ScrollView {
id: scrView
property double scale: 0.5
scrollViewProperties.pinchToZoomEnabled: true
TextArea {
id: promptText
text: <text here>
editable: false
textStyle.fontSize: FontSize.XXLarge
textStyle.color: Color.White
scrollMode: TextAreaScrollMode.Stiff
}
gestureHandlers: [
PinchHandler {
onPinchUpdated: {
scrView.contentScale = (scale * event.pinchratio)
}
}
]
}
What I want to do is to be able to push a play button, which starts scrolling the textarea.
I've looked in the forums, but in vain.
At this time I'm trying something like this in my QML:
function startScrolling() {
while (location < 1000) {
location = location + 0.5
scrView.scrollToPoint(0, location)
}
}
The textarea scrolls, but not fluidly; it waits for like 5 seconds and then jumps to the fifth line.
Am I missing something?
Thx,
Johan
Solved! Go to Solution.
02-14-2013 08:11 AM
You have to do the animation in a seperate thread I guess. Or maybe take a look at the explicit animations?
https://developer.blackberry.com/cascades/document
Maybe their is something you can use for the thing you want.
02-14-2013 08:21 AM
Thx Curahee for the swift response/suggestion.
I will see if this gets me back on track
02-14-2013 01:17 PM
Hi,
You're sending all the updates at once so they're processed instantly and only the last one is seen. The delay is due to the processing of all the accumulated messages.
Starting a thread is probably an overkill in this situation and I think the GUI must be updated from main thread anyway.
I'd use a timer. There is a snippet for starting a timer in QML (search for 'QTimer'):
https://developer.blackberry.com/cascades/document
On button press start a timer with small interval, for example 50 msec.
In onTimeout handler call scrollToPoint once or stop the timer if the scrolling is done.
Store the current position in a property.
Please note that scrollToPoint scrolls smoothly to the destination by default, so if you're updating the position in small steps manually you'll have to disable smooth scrolling by passing a third parameter:
scrView.scrollToPoint(0, location, ScrollAnimation.None)
02-15-2013 06:52 AM
Thx for the suggestion.
I've been looking at the QTimer option, following directions from this tutorial:
Everything compiles and builds, but my app is unresponsive the moment i include the CustomTimer or QTimer in my qml.
import bb.cascades 1.0
import bb.cascades.pickers 1.0
//import prompter.Timer 1.0
//import MyTimer 1.0
import CustomTimer 1.0
Page {
I've tried creating a CustomControl and registering the QTimer directly.
Without the import, everything builds, runs, but NO timer functionality.
With the import (without even creating a (Q)Timer element inside the Container element), it builds BUT on my Dev Alpha i keep on seeing the splashscreen of BlackBerry 10 after opening the app.
Any suggestions? How to debug this?
FYI: when importing the SignalsAndSlots sample in QNX and deploying it to my device, that app is running as it should...
02-15-2013 07:07 AM
02-15-2013 08:37 AM
Think I found the problem.
I have 3 classes:
app.cpp (containing some logic)
MyClass.cpp (Generated file for project)
main.cpp
What I did, was register the QTimer in MyClass.cpp, but app.cpp was the one that did all the GUI-glue ...
So adding qmlRegisterType<QTimer>("my.library", 1, 0, "QTimer"); as first line inside App::App resulted in a GUI.
Oh yeah ...And I also needed to add LIBS += -lbbsystem to my .pro file in order to be able to debug.
Next step ... implementing the timer logic ![]()
02-15-2013 09:10 AM
And we're scrolling!! ![]()
onTimeout: {
location = location + 1
scrView.scrollToPoint(0, location)
}