Capturing the view close "x"
So, can you capture the event of the "x" in the upper left hand corner of a presented ui.view being touched to allow for a cleanup before the whole script stops? I tried the obvious "finally", but that didn't fire, only the console upper right hand X did that.
Two techniques to look at:
I assume this is a custom view, in which case, did you try
def will_close(self): # This will be called when a presented view is about to be dismissed. # You might want to save data here. pass
However, I vaguely recall this working for some types of presentation modes (say, popover), but not others, but I could be wrong about that.
Another alternative to the blocking options that ccc suggests would be a
Timerthat polls the
on_screenat some reasonably slow interval (few seconds).
One other option... hide the title bar and provide your own "X". Doesn't protect against two finger swipes, but most people don't know about that anyway.