10-01-2012 01:00 PM
Hey all,
Just finished my first Cascades app. Love it!
The one thing I'm still looking for is some way to keep the display alive while certain things are happening in my app (playing an animation). Is there a way to (Temporarily) tell the device to not put the display to sleep in Cascades?
Thanks!
Marco
Staff UI Prototyper (read: full-time hacker)
My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App
Solved! Go to Solution.
10-01-2012 01:02 PM - edited 10-01-2012 01:05 PM
Searching for "keepawake" instead of "keepalive" leads me here: https://developer.blackberry.com/cascades/referenc
(And by the way, no, I don't think that's a complete answer yet. I'm not sure how it would be used to address your question but it's going to be involved in the answer, unless you dive down to non-Cascades native stuff.)
10-01-2012 01:09 PM
That looks like what I need. Question is though: Where would I put it?
I have a 'Sheet' which comes up at certain times. Only when this sheet is shown I want to keep the screen alive.
I tried putting it inside the Page {}, Container{} and WebView{} (got these three nested) but for all three Momentix complains ScreenIdleMode being an unknown property.
Staff UI Prototyper (read: full-time hacker)
My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App
10-01-2012 01:19 PM
Well, it appears you'd be expected to do this:
# presumed intended use Application.mainWindow.screenIdleMode = ScreenIdleMode.KeepAwake; # possible workaround for non-exported (?) name ScreenIdleMode Application.mainWindow.screenIdleMode = 1;
That's using the fact that the main window is exposed via https://developer.blackberry.com/cascades/referenc
So far, it appears to be working in a "study" app I have here for experimentation. Not when the app is minimized, mind you, which appears to be a change in behaviour from pre-BB10 where having any portion of the app's window visible was enough (when set to KeepAwake) to keep the screen from blanking. (I don't disagree with the change... having the screen controlled by apps which aren't fullscreen is a dubious situation.)
10-01-2012 01:25 PM
Sorry if this sounds ignorant but: in which file would I put this line?
Staff UI Prototyper (read: full-time hacker)
My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App
10-01-2012 01:46 PM
Think you can put that any where as its referencing the application instance, which is a global singleton to your application
10-01-2012 01:49 PM
10-01-2012 02:01 PM
Ok I now feel like an even bigger **bleep**...
Can you post a QML snipped with this in it? I can't seem to figure it out
![]()
Staff UI Prototyper (read: full-time hacker)
My BB10 apps: Screamager | Scientific RPN Calculator | The Last Weather App
10-01-2012 02:24 PM
Complete QML:
import bb.cascades 1.0
Page {
Container {
Label {
id: label
text: "KeepAwake is " + (Application.mainWindow.screenIdleMode ? "ON" : "OFF")
}
ToggleButton {
onCheckedChanged: Application.mainWindow.screenIdleMode = checked ? 1 : 0;
}
}
}
10-01-2012 02:28 PM
By the way, it appears there's a good reason why the ScreenIdleMode enum is not available to us yet. I believe it's because it's been made private, probably by mistake:
class QT_CASCADES_EXPORT ScreenIdleMode
{
private:
Q_GADGET
Q_ENUMS (Type)
...
I could be wrong... not sure how things get exposed to QML in general, but I've checked some other enums to which we do have access and they have Q_ENUMS() under "public".