Page 1 of 1

Quit an app

Posted: Sun May 25, 2014 8:37 pm
by D4vidrim
Hi!
New basic question:
I have a main stack and a substack and I want the app to quit if I clic on the X of the main stack and to just close the substack if I clic on its X.

If I put his code on the main stack:
on closeStack
quit
end closeStack

and this code on the other substacks:
on closeStack
end closeStack

it works fine, but I was wondering if there is a better way to reach the same goal!

Thank you, Davide

Re: Quit an app

Posted: Sun May 25, 2014 9:02 pm
by sefrojones
Would something like this work? Just put it into the main stack script, and i think it will do what you're asking.

Code: Select all

on closestackrequest
   put the owner of the target into tStackTitle
   set the itemdelimiter to space
   delete item 1 of tStackTitle
   replace quote with empty in tStackTitle
   if tStackTitle is "MyMainStack" then
      quit
   else
      close stack tStackTitle
   end if
end closestackrequest


Not sure if that's the best way to go about it, but maybe it's what you're looking for.


edit: removed the line that replaced space with empty, as this would mess things up if there was a space in your stack titles

Re: Quit an app

Posted: Sun May 25, 2014 9:33 pm
by sefrojones
As a matter of fact, maybe this one is a little better.

Code: Select all

on closestackrequest
   put the short name of the owner of the target into tStackTitle
   if tStackTitle is "MyMainStack" then
   quit
   else
      close stack tStackTitle
      end if
end closestackrequest

Re: Quit an app

Posted: Mon May 26, 2014 7:16 am
by atout66
Hi to all,
I want to thank you sefrojonesGAda40, because I had the same question than D4vidrim and your last example is exactly what I needed :wink:
Great forum !

Cheers, Jean-Paul.

Re: Quit an app

Posted: Mon May 26, 2014 9:46 am
by D4vidrim
it works very well, thanks!