You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by "Erik J. Thomas" <er...@linqto.com> on 2018/10/15 22:16:54 UTC

Detecting window resize complete on AIR native desktop

Creating an AIR desktop app and need to know when the nativeWindow has been resized by the user. This sounds easy:

stage.nativeWindow.addEventListener(NativeWindowBoundsEvent.RESIZE, onResize);

This listener fires the event every 100ms or so while the user drags the window edge. I need to know when the user is finished resizing the window. 

Also, listening for stage.MouseEvent.MOUSE_UP when the user is finished resizing the window does not fire. NativeDragEvent.NATIVE_DRAG_COMPLETE does not fire either. 

Here is trace output:

[trace] 15:02:27:128 onResize() - nativeWindows.width: 911
[trace] 15:02:27:239 onResize() - nativeWindows.width: 884
[trace] 15:02:27:358 onResize() - nativeWindows.width: 866
[trace] 15:02:27:475 onResize() - nativeWindows.width: 844
[trace] 15:02:27:593 onResize() - nativeWindows.width: 820
[trace] 15:02:27:677 onResize() - nativeWindows.width: 805
[trace] 15:02:27:762 onResize() - nativeWindows.width: 799
[trace] 15:02:27:842 onResize() - nativeWindows.width: 788
[trace] 15:02:27:935 onResize() - nativeWindows.width: 778
... 

Thanks for your ideas.

Here's the API docs - I see nothing I can use to reliably solve this issue.
https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html <https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html>



Re: Detecting window resize complete on AIR native desktop

Posted by Erik Thomas <er...@icloud.com>.
Good idea, I'll post on adobe forum and hope for a better suggested workaround. Thanks, Alex.

Cheers,

Erik


Re: Detecting window resize complete on AIR native desktop

Posted by Alex Harui <ah...@adobe.com.INVALID>.
Hi Erik,

I'm not saying Adobe would make a change to AIR, but they might have an idea for a workaround we haven't considered.

It has been a long time since I wrote code for Microsoft Windows apps, but I think the default behavior is that a resizable OS window doesn't require managing mouse events, just responding to a resize event as well.  There are probably ways to get the mouse events and forward them, but the x,y coordinates would be outside the stage dimensions.

BTW, did you check if you get a MOUSE_LEAVE event?

To me, this is similar to any animation problem in Flash/AIR.  You are trying to hit a particular frame rate, and screen update time is too long.  One quick/cheap hack to try is to defer the entire resize update via callLater.  More sophisticated implementations queue the deferred work and make decisions about how to respond when things are in the queue.

HTH,
-Alex

On 10/16/18, 10:29 AM, "Erik Thomas" <er...@icloud.com> wrote:

    Thanks, Alex, but spending time optimizing this kludge just isn't worth the effort with my current backlog. Just wish there was a better way, a correct way. 
    
    I could log a feature request on Adobe, but it would never get enough votes. Just seems a no-brainer that the AIR runtime should fire a MOUSE_UP event to the stage when the user releases the mouse while dragging the chrome, or allow accessing the chrome from the app and adding event listeners. Seems simple enough. They do it already for resize, why not mouse up?
    
    Thanks.
    
    Erik
    
    On Oct 16, 2018, at 10:07 AM, Alex Harui <ah...@adobe.com.INVALID> wrote:
    
    Erik,
    
    Did you also ask on the Adobe forums?
    
    I'm not sure that AIR will give you mouse events when the mouse is interacting with the "chrome" of a Window.  IOW, I don't think the mouse ever touched the pixels that represent the SWF content.
    
    You could write a test to see if the resize event interval is dependent on how long it takes for your app to respond to a resize event.  Create a HelloWorld app that will redraw very quickly and see if you get resize events more often.
    
    If AIR can deliver resize events at, say 50ms in a simple app, then you can consider making changes to your app to respond to resize more quickly.  You can use the performance profilers to see if there are bottlenecks responding to resize.  You can also consider deferring certain kinds of work via callLater.
    
    HTH,
    -Alex
    
    On 10/16/18, 9:53 AM, "Erik Thomas" <erikjthomas@icloud.com <ma...@icloud.com>> wrote:
    
       Yeah, I figured I'd have to use a timer kludge like in the SO thread. Just one more of those things about AIR that annoys me.
    
       I've implemented that pattern and it's working, though the resize events fire at roughly 200ms intervals during a drag. A 50ms timer interval suggested in SO of course couldn't work. I had to implement a 300ms timer interval to be reliably notified only after the resizing process ends with the user releasing the mouse capture. 
    
       But it should be possible to get the mouse up event after the resize. That should be considered a bug in AIR, IMO.
    
       The timer kludge results in delaying a REST API call for 300ms from the last resize event is received, making the app appear noticeably unresponsive. 
    
       Thanks for your response, Kyle. I guess I'll just have to live with it.
    
       Cheers
    
       Erik
    
       On Oct 15, 2018, at 3:33 PM, kamcknig <ka...@gmail.com> wrote:
    
       As far as I know there isn't a way, a stackoverflow user asked the same 
    
       https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F11014968%2Fdetect-when-the-resize-event-has-finished&amp;data=02%7C01%7Caharui%40adobe.com%7C61ea030b7b094f7503f008d6338cf596%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636753077852684438&amp;sdata=Sta%2FJ8fFFsdvFyCCIEjnDp0qJR4%2BAJRMNcC2bQp0l0k%3D&amp;reserved=0 <https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F11014968%2Fdetect-when-the-resize-event-has-finished&amp;data=02%7C01%7Caharui%40adobe.com%7C61ea030b7b094f7503f008d6338cf596%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636753077852684438&amp;sdata=Sta%2FJ8fFFsdvFyCCIEjnDp0qJR4%2BAJRMNcC2bQp0l0k%3D&amp;reserved=0>
    
       I can't think of any way to do so.
    
       Kyle
    
    
    
       --
       Sent from: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-flex-users.2333346.n4.nabble.com%2F&amp;data=02%7C01%7Caharui%40adobe.com%7C61ea030b7b094f7503f008d6338cf596%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636753077852684438&amp;sdata=vfy0FIcb%2Bx%2F2a5jV9ptbMVOxRJfyqwbjJ4X9DGka1iU%3D&amp;reserved=0 <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-flex-users.2333346.n4.nabble.com%2F&amp;data=02%7C01%7Caharui%40adobe.com%7C61ea030b7b094f7503f008d6338cf596%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636753077852684438&amp;sdata=vfy0FIcb%2Bx%2F2a5jV9ptbMVOxRJfyqwbjJ4X9DGka1iU%3D&amp;reserved=0>
    


Re: Detecting window resize complete on AIR native desktop

Posted by Erik Thomas <er...@icloud.com>.
Thanks, Alex, but spending time optimizing this kludge just isn't worth the effort with my current backlog. Just wish there was a better way, a correct way. 

I could log a feature request on Adobe, but it would never get enough votes. Just seems a no-brainer that the AIR runtime should fire a MOUSE_UP event to the stage when the user releases the mouse while dragging the chrome, or allow accessing the chrome from the app and adding event listeners. Seems simple enough. They do it already for resize, why not mouse up?

Thanks.

Erik

On Oct 16, 2018, at 10:07 AM, Alex Harui <ah...@adobe.com.INVALID> wrote:

Erik,

Did you also ask on the Adobe forums?

I'm not sure that AIR will give you mouse events when the mouse is interacting with the "chrome" of a Window.  IOW, I don't think the mouse ever touched the pixels that represent the SWF content.

You could write a test to see if the resize event interval is dependent on how long it takes for your app to respond to a resize event.  Create a HelloWorld app that will redraw very quickly and see if you get resize events more often.

If AIR can deliver resize events at, say 50ms in a simple app, then you can consider making changes to your app to respond to resize more quickly.  You can use the performance profilers to see if there are bottlenecks responding to resize.  You can also consider deferring certain kinds of work via callLater.

HTH,
-Alex

On 10/16/18, 9:53 AM, "Erik Thomas" <erikjthomas@icloud.com <ma...@icloud.com>> wrote:

   Yeah, I figured I'd have to use a timer kludge like in the SO thread. Just one more of those things about AIR that annoys me.

   I've implemented that pattern and it's working, though the resize events fire at roughly 200ms intervals during a drag. A 50ms timer interval suggested in SO of course couldn't work. I had to implement a 300ms timer interval to be reliably notified only after the resizing process ends with the user releasing the mouse capture. 

   But it should be possible to get the mouse up event after the resize. That should be considered a bug in AIR, IMO.

   The timer kludge results in delaying a REST API call for 300ms from the last resize event is received, making the app appear noticeably unresponsive. 

   Thanks for your response, Kyle. I guess I'll just have to live with it.

   Cheers

   Erik

   On Oct 15, 2018, at 3:33 PM, kamcknig <ka...@gmail.com> wrote:

   As far as I know there isn't a way, a stackoverflow user asked the same 

   https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F11014968%2Fdetect-when-the-resize-event-has-finished&amp;data=02%7C01%7Caharui%40adobe.com%7C24b8a1c31a414de69b1d08d63387ea45%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636753056182036471&amp;sdata=w9Z9HLrbWsUyUDBHraKSKuqerX1O%2FLoYBqbpFLslMNE%3D&amp;reserved=0 <https://na01.safelinks.protection.outlook.com/?url=https://stackoverflow.com/questions/11014968/detect-when-the-resize-event-has-finished&amp;data=02|01|aharui@adobe.com|24b8a1c31a414de69b1d08d63387ea45|fa7b1b5a7b34438794aed2c178decee1|0|0|636753056182036471&amp;sdata=w9Z9HLrbWsUyUDBHraKSKuqerX1O/LoYBqbpFLslMNE=&amp;reserved=0>

   I can't think of any way to do so.

   Kyle



   --
   Sent from: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-flex-users.2333346.n4.nabble.com%2F&amp;data=02%7C01%7Caharui%40adobe.com%7C24b8a1c31a414de69b1d08d63387ea45%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636753056182036471&amp;sdata=sD%2FloMMx%2BfXptvCzlcPFR%2B5imOqL%2BKR6o5WjeU7SWUk%3D&amp;reserved=0 <https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-flex-users.2333346.n4.nabble.com%2F&amp;data=02%7C01%7Caharui%40adobe.com%7C24b8a1c31a414de69b1d08d63387ea45%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636753056182036471&amp;sdata=sD%2FloMMx%2BfXptvCzlcPFR%2B5imOqL%2BKR6o5WjeU7SWUk%3D&amp;reserved=0>

Re: Detecting window resize complete on AIR native desktop

Posted by Alex Harui <ah...@adobe.com.INVALID>.
Erik,

Did you also ask on the Adobe forums?

I'm not sure that AIR will give you mouse events when the mouse is interacting with the "chrome" of a Window.  IOW, I don't think the mouse ever touched the pixels that represent the SWF content.

You could write a test to see if the resize event interval is dependent on how long it takes for your app to respond to a resize event.  Create a HelloWorld app that will redraw very quickly and see if you get resize events more often.

If AIR can deliver resize events at, say 50ms in a simple app, then you can consider making changes to your app to respond to resize more quickly.  You can use the performance profilers to see if there are bottlenecks responding to resize.  You can also consider deferring certain kinds of work via callLater.

HTH,
-Alex

On 10/16/18, 9:53 AM, "Erik Thomas" <er...@icloud.com> wrote:

    Yeah, I figured I'd have to use a timer kludge like in the SO thread. Just one more of those things about AIR that annoys me.
    
    I've implemented that pattern and it's working, though the resize events fire at roughly 200ms intervals during a drag. A 50ms timer interval suggested in SO of course couldn't work. I had to implement a 300ms timer interval to be reliably notified only after the resizing process ends with the user releasing the mouse capture. 
    
    But it should be possible to get the mouse up event after the resize. That should be considered a bug in AIR, IMO.
    
    The timer kludge results in delaying a REST API call for 300ms from the last resize event is received, making the app appear noticeably unresponsive. 
    
    Thanks for your response, Kyle. I guess I'll just have to live with it.
    
    Cheers
    
    Erik
    
    On Oct 15, 2018, at 3:33 PM, kamcknig <ka...@gmail.com> wrote:
    
    As far as I know there isn't a way, a stackoverflow user asked the same 
    
    https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F11014968%2Fdetect-when-the-resize-event-has-finished&amp;data=02%7C01%7Caharui%40adobe.com%7C24b8a1c31a414de69b1d08d63387ea45%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636753056182036471&amp;sdata=w9Z9HLrbWsUyUDBHraKSKuqerX1O%2FLoYBqbpFLslMNE%3D&amp;reserved=0
    
    I can't think of any way to do so.
    
    Kyle
    
    
    
    --
    Sent from: https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fapache-flex-users.2333346.n4.nabble.com%2F&amp;data=02%7C01%7Caharui%40adobe.com%7C24b8a1c31a414de69b1d08d63387ea45%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C636753056182036471&amp;sdata=sD%2FloMMx%2BfXptvCzlcPFR%2B5imOqL%2BKR6o5WjeU7SWUk%3D&amp;reserved=0
    
    
    


Re: Detecting window resize complete on AIR native desktop

Posted by Erik Thomas <er...@icloud.com>.
Yeah, I figured I'd have to use a timer kludge like in the SO thread. Just one more of those things about AIR that annoys me.

I've implemented that pattern and it's working, though the resize events fire at roughly 200ms intervals during a drag. A 50ms timer interval suggested in SO of course couldn't work. I had to implement a 300ms timer interval to be reliably notified only after the resizing process ends with the user releasing the mouse capture. 

But it should be possible to get the mouse up event after the resize. That should be considered a bug in AIR, IMO.

The timer kludge results in delaying a REST API call for 300ms from the last resize event is received, making the app appear noticeably unresponsive. 

Thanks for your response, Kyle. I guess I'll just have to live with it.

Cheers

Erik

On Oct 15, 2018, at 3:33 PM, kamcknig <ka...@gmail.com> wrote:

As far as I know there isn't a way, a stackoverflow user asked the same 

https://stackoverflow.com/questions/11014968/detect-when-the-resize-event-has-finished

I can't think of any way to do so.

Kyle



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/



Re: Detecting window resize complete on AIR native desktop

Posted by kamcknig <ka...@gmail.com>.
As far as I know there isn't a way, a stackoverflow user asked the same 

https://stackoverflow.com/questions/11014968/detect-when-the-resize-event-has-finished

I can't think of any way to do so.

Kyle



--
Sent from: http://apache-flex-users.2333346.n4.nabble.com/