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

Adobe AIR Development

Reply
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Minimize application event.

@jtegen, by the way, the events even fired on 1.0.6 and earlier. They just reflect the actual window state properly, instead reflecting the activation state (normal was activated, thumbnail was deactivated, or something like that). So if you're not even receiving the events, it's nothing to do with the update.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Minimize application event.

I've migrated the code to 4.5.1 of FB so I am using the correct SDK and with AIR 2.7 and I still cannot get the events to fire. I have it setup in the constructor of my root Sprite. How are you establishing the event listening?
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Minimize application event.

John, I'll post a one-file sample app in a few minutes for you.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Minimize application event.

No rush and thanks. I have to leave in a bit so I wont see it till tomorrow.
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Minimize application event.

Here you go.  This works for me with SDK 1.1.0 and OS 1.0.7, with Default mode, but there's no reason you shouldn't see events on any version of the OS, even if the values will not be as they are with 1.0.7.

 

package {
    import flash.display.Sprite;
    import flash.text.TextFormat;
    import flash.utils.*;

    import qnx.display.IowWindow;
    import qnx.events.IowWindowEvent;
    import qnx.ui.text.Label;


    [SWF(backgroundColor="#cccccc", width="1024", height="600")]
    public class WindowStateTest extends Sprite {
        public var label:Label;
        public var win:IowWindow;

        public function WindowStateTest()
        {
            win = IowWindow.getAirWindow();
            win.addEventListener(IowWindowEvent.WINDOW_STATE_CHANGED, onWinEvent);

            label = new Label();
            addChild(label);
            label.x = label.y = 50;
            label.width = 800;
            label.height = 50;
            label.text = status_text();

            var fmt:TextFormat = label.format;
            fmt.size = 36;
            label.format = fmt;
        }

        public function onWinEvent(e:IowWindowEvent):void {
            var text:String = status_text();
            label.text = text;
            trace(text);
        }

        public function status_text():String {
            return getTimer() + ': state=' + win.state + ', visibility=' + win.visible;
        }
    }
}

Obviously best if you run with the debugger attached, or convert the above to record/display a log of the recent events, or you'll have a hard time seeing the "hidden" state...


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: Minimize application event.

Thanks Peter: Dont know why, but it works now. Very strange.
BlackBerry Development Advisor
Posts: 15,753
Registered: ‎07-09-2008
My Device: BlackBerry PRIV
My Carrier: Bell

Re: Minimize application event.


peter9477 wrote:

 

5. If the user top-corner-swipes and then selects the Settings icon, the settings pages slide down over top of your window but your window does not show as "hidden".  This is the only corner case I've found which may represent an actual mistake, since as far as I can see no part of your window is actually visible.

 


Good catch!  I've logged this in issue tracker here:  https://www.blackberry.com/jira/browse/TABLET-295

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
New Contributor
Posts: 3
Registered: ‎05-24-2011
My Device: Torch 9800
My Carrier: Fido

Re: Minimize application event.

[ Edited ]

@jtegen:

 

If you paste the whole thing inside a function (i.e. you have a function inside another function), then the stateChanged() function must go before the addEventListener() line, otherwise no listener will be added.

Highlighted
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Minimize application event.

If you were writing code like this, it appears you may be right:

var stateChanged:Function = function(e:IowWindowEvent):void { ... };

If you write it this way, however, it makes no difference in the bytecode generated, so that can't be the answer.  (I just checked that manually.)

function stateChanged(e:IowWindowEvent):void { ... }

Julian's post used the later approach, so unless John changed it around without thinking, there must be a different explanation.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!