Make a dialog if I press the „x“
-
On my Scene is on the left the „x“ to leave, how can I make a dialog that if I press the „x“ there come a dialog: Are you sure to leave?
-
@mikael more than nice, sometimes i wonder what i'm doing here
-
@cvp, you are being polite, it was your idea.
-
@mikael I have first tried to change target action of close UIButton, possible but not so easy because some consequences.
-
@cvp @mikael Thanks a lot, that‘s awesome, but can I also create my Scene with ui or must I have it with the module „Scene“
-
That here is my code, but it doesn‘t work really:
import ui import console from scene import * class Scene(ui.View): def __init__(self): self.background_color = 'gray' self.name = 'Test' #def close(self,sender): self.paused = True if console.alert('Close Scene?','','Yes','No',hide_cancel_button=True) == 1: self.view.close() self.paused = False s = Scene() s.present('fullscreen')
-
@Python567 why is your Scene an ui.View? See @mikael 's code
-
@Python567 if you want to use an ui.View, try
import ui import console from scene import * class Scene(ui.View): def __init__(self): self.background_color = 'gray' self.name = 'Test' def will_close(self): #self.paused = True if console.alert('Close Scene?','','Yes','No',hide_cancel_button=True) == 2: return #self.paused = False s = Scene() s.present('fullscreen')
-
@cvp the code from @mikael is with with the Scene module, but I already have all of my Programm with ui, so...
-
@cvp if I click „no“ on your code, the skript will close completely!
-
@Python567 you're right. Shame on me. I forgot that, like scene.stop, view.will_close allow to add process at end but not to avoid closing. Thus, you have to present without title and to build your own close button
-
import ui import console class Scene(ui.View): def __init__(self): self.background_color = 'gray' self.name = 'Test' self.add_subview(ui.Button(frame=(2,12,32,32),title='x',action=self.bclose)) def bclose(self,sender): if console.alert('Close Scene?','','Yes','No',hide_cancel_button=True) == 2: return self.close() s = Scene() s.present('fullscreen', hide_title_bar=True)
-
@cvp thanks