Modal background is not centered if modal is shown while minimized

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Modal background is not centered if modal is shown while minimized

kamcknig
I'm using Flex 4.15, AIR 20.0.

I have an idle timer on my app that logs a user out after a certain amount of time. If I start my app and then minimize it immediately and wait for the idle time to pass so that the modal is shown while it's minimized and then restore the window, the modal background is centered around the top-left corner rather than being centered in the application. If I use PopUpManager I can center the modal itself, but the background is still off-center. Anyone know how to get that centered? Should I just hide and reshow the modal?



Kyle McKnight
Senior UI Engineer - Accesso
602.515.1444 (M)
Reply | Threaded
Open this post in threaded view
|

Re: Modal background is not centered if modal is shown while minimized

kamcknig
Reply | Threaded
Open this post in threaded view
|

Re: Modal background is not centered if modal is shown while minimized

Nemi
In reply to this post by kamcknig
I had that issue too. That is a bug. I think its reported, but don't recall the issue ID. Problem could be that PopUpManager somewhere reads nativeWindow/window/parent size, and if nativeWindow is minimized, size is 0,0 so there bug happens.

Try this workaround/fix:
1. listen window's native display change state event,
2. and within it, check if prev state was minimized, and new state is not (means: user is restoring window)
3. then if true, loop all popup children, check ones you look for (read class name, or "modalWindow" property of popup child), re-position it and its background sprite, and set sprites size as parent window's one.
4. user wont notice repositioning and all looks nice

Test it quickly this way: create sample app, with button that does: minimize app, than after 1 second, creates popup or better few of them(as you can have more popups in app). When you restore app window, if all popups are where they should be, you fixed it.

Helpful links:
https://stackoverflow.com/questions/7323505/flex-how-to-determine-if-a-popupmanager-window-is-open-or-when-it-has-closed
https://weflex.wordpress.com/tag/popupmanager/
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/managers/PopUpManagerChildList.html
Reply | Threaded
Open this post in threaded view
|

Re: Modal background is not centered if modal is shown while minimized

kamcknig
Great! This is what I suspected but wanted to ask before I delved into the
SDK source to solve it.

Thanks for the suggestion!

On Jun 6, 2017 1:26 PM, "Nemi" <[hidden email]> wrote:

> I had that issue too. That is a bug. I think its reported, but don't recall
> the issue ID. Problem could be that PopUpManager somewhere reads
> nativeWindow/window/parent size, and if nativeWindow is minimized, size is
> 0,0 so there bug happens.
>
> Try this workaround/fix:
> 1. listen window's native display change state event,
> 2. and within it, check if prev state was minimized, and new state is not
> (means: user is restoring window)
> 3. then if true, loop all popup children, check ones you look for (read
> class name, or "modalWindow" property of popup child), re-position it and
> its background sprite, and set sprites size as parent window's one.
> 4. user wont notice repositioning and all looks nice
>
> Test it quickly this way: create sample app, with button that does:
> minimize
> app, than after 1 second, creates popup or better few of them(as you can
> have more popups in app). When you restore app window, if all popups are
> where they should be, you fixed it.
>
> Helpful links:
> https://stackoverflow.com/questions/7323505/flex-how-to-
> determine-if-a-popupmanager-window-is-open-or-when-it-has-closed
> https://weflex.wordpress.com/tag/popupmanager/
> http://help.adobe.com/en_US/FlashPlatform/reference/
> actionscript/3/mx/managers/PopUpManagerChildList.html
>
>
>
> --
> View this message in context: http://apache-flex-users.
> 2333346.n4.nabble.com/Modal-background-is-not-centered-if-
> modal-is-shown-while-minimized-tp15286p15288.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Modal background is not centered if modal is shown while minimized

Nemi
Great that I helped. No need to delve into SDK source.

I found the bug: https://issues.apache.org/jira/browse/FLEX-16946

Some notes:
More performant way to move popups is popupitem.move(x,y)

To get background FlexSprite, I used:
bgsprite = systemManager.getChildAt(popupsitemIndex - 1)

then checked: if bgsprite.name = "modelWindow"

then you use bgsprite.graphics to redraw it:
- clear()
- beginFill(..use your default Alert CSS style values...)
- drawRect(0,0,win.width, win.height) to stretch it fullscreen
Reply | Threaded
Open this post in threaded view
|

Re: Modal background is not centered if modal is shown while minimized

kamcknig
Perfect, thanks!

On Jun 6, 2017 1:52 PM, "Nemi" <[hidden email]> wrote:

> Great that I helped. No need to delve into SDK source.
>
> I found the bug: https://issues.apache.org/jira/browse/FLEX-16946
>
> Some notes:
> More performant way to move popups is popupitem.move(x,y)
>
> To get background FlexSprite, I used:
> bgsprite = systemManager.getChildAt(popupsitemIndex - 1)
>
> then checked: if bgsprite.name = "modelWindow"
>
> then you use bgsprite.graphics to redraw it:
> - clear()
> - beginFill(..use your default Alert CSS style values...)
> - drawRect(0,0,win.width, win.height) to stretch it fullscreen
>
>
>
>
> --
> View this message in context: http://apache-flex-users.
> 2333346.n4.nabble.com/Modal-background-is-not-centered-if-
> modal-is-shown-while-minimized-tp15286p15292.html
> Sent from the Apache Flex Users mailing list archive at Nabble.com.
>