ShowModal Closed

If I show a modal view over another view and then close the modal view what event should be triggered on the originating view? Nothing happens in the Activate Event,so how do I know the modal view has closed?

Var v As New QuestView
v.ShowModal(Nil,mobilescreen.ModalPresentationStyles.Popover,true)

The Closing event to the view will be fired.

What doesn’t the Activated event of the view that becomes current fire? Would I have to set a flag in the closing event and run a timer on the current view to check it is now the current view??

What happens if you set the parentview to not be Nil? Do you get an activated event on it then?

The docs say it should fire if a subview has been closed:
https://documentation.xojo.com/api/user_interface/mobile/mobilescreen.html#mobilescreen-activated

Is it because I set (parent As MobileScreen = Nil) that no event is fired when it closes?

I don’t know just try it or wait for someone at xojo to answer. I think the Activated should always fire of the calling parent view since the docs say so and seems logical. And since it does actually bring that view back.

Not sure why your activated event is not firing.

Example project on link below using API 2.0 only. Two screens, the first screen has all events in it with a break point. Upon opening 3 events fire Opening, Activated and Resized. Press the modal button and the modal window opens over the main. Press the CLOSE button it closes showing MAIN but no events fire. Probably not a bug so I must be missing something.

https://www.rushsoftware.com.au/Files/Test%20ShowModal.xojo_binary_project.zip

Any takers to confirm if these events are not firing?

Activated is not called on the originating window when a modal screen is closed. We have the Activated event hooked into the UIKit viewWillAppear() method and this appears to be its standard behavior.

However, it might be possible that we could call the parent Activated event when the modal view closes. If this is important to you, please create a Feedback case so we can look into it further.

Thanks Paul, will do. For the time being I am running a timer on the parent waiting for a Boolean to say it’s closed. I would think it would be handy for others as IAPs are often offered on a modal window.

In 2020r2.1, the modal view’s Closed event will now consistently fire when Close is called on the view or the user swipes down to dismiss, so you could use AddHandler on that.

4 Likes

Thank you for fixing this so quickly.