Forum Archive

Any way to hook into the Close Button of a Share extension?

halloleooo

With the help of the generous advice of the people on this forum I have written a image extension. So far, so good, so happy.

Let's look at the work flow: Say, in the Files app I have selected some images, then go to Share --> Pyhonista --> My Script and then the Image UI opens:

Now when I decide I want close the UI I do this via the Close button (circled in the screenshot). However the Pyhonista script selector stays visible then. Programmatically I know I can dismiss it with appex.finish(), but how can I hook this call up to the Close button?

Any idea?

cvp

@halloleooo so easy 😀 (or I didn't understand the question)

import ui

import appex

class MyView(ui.View):
    def __init__(self):
        pass
    def will_close(self):
        appex.finish()

def main():
    v = MyView()
    v.present()

if __name__ == '__main__':
    main()
cvp

@halloleooo is it ok?

halloleooo

Thanks @cvp. Works a treat! That's exactly what I want.

I wasn't aware of will_close but, of course, I found it now in the doco.