Exit loop

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Exit loop

Javier Reyes-2
Hello All,

I am trying to create a button or morph that when pressed stores the present Squeak image and exits Squeak. I have tried both with a PluggableButtonMorph with its action associated and with a plain rectangleMorph defining its mouseDown method as follows:

mouseDown: anEvent
SmalltalkImage current saveImageInFileNamed: (SmalltalkImage current imageName).
Smalltalk quitPrimitive.


In both cases pressing the morph performs as expected, but when I try to launch that image back and the application with it, it seems to be looped into that event again exiting immediately.

I know I am missing something important.  Could someone explain me what it is ?

Thanks very much in advance.

             Javier Reyes


Reply | Threaded
Open this post in threaded view
|

Re: Exit loop

Tom Phoenix
On 10/7/07, Javier Reyes <[hidden email]> wrote:

> I am trying to create a button or morph that when pressed stores the present
> Squeak image and exits Squeak.

This works for me:

  TheWorldMenu new saveAndQuit

But if you want to go one level lower, you could use this:

  SmalltalkImage current snapshot: true andQuit: true

Hope this helps!

--Tom Phoenix

Reply | Threaded
Open this post in threaded view
|

Re: Exit loop

Javier Reyes-2
Works for me too !!  :-)

Thanks

On 10/8/07, Tom Phoenix <[hidden email]> wrote:
On 10/7/07, Javier Reyes <[hidden email]> wrote:

> I am trying to create a button or morph that when pressed stores the present
> Squeak image and exits Squeak.

This works for me:

  TheWorldMenu new saveAndQuit

But if you want to go one level lower, you could use this:

  SmalltalkImage current snapshot: true andQuit: true

Hope this helps!

--Tom Phoenix




Reply | Threaded
Open this post in threaded view
|

Re: Exit loop

Bert Freudenberg
In reply to this post by Javier Reyes-2

On Oct 8, 2007, at 0:30 , Javier Reyes wrote:

> Hello All,
>
> I am trying to create a button or morph that when pressed stores  
> the present Squeak image and exits Squeak. I have tried both with a  
> PluggableButtonMorph with its action associated and with a plain  
> rectangleMorph defining its mouseDown method as follows:
>
> mouseDown: anEvent
> SmalltalkImage current saveImageInFileNamed: (SmalltalkImage  
> current imageName).
> Smalltalk quitPrimitive.
>
>
> In both cases pressing the morph performs as expected, but when I  
> try to launch that image back and the application with it, it seems  
> to be looped into that event again exiting immediately.
>
> I know I am missing something important.  Could someone explain me  
> what it is ?

Sure.  "Saving" an image means simply to stop time. So time stops  
"inside" of #saveImageInFileNamed:, and when you resume the image,  
the first thing it executes is ... quitPrimitive. That's why we have  
that method that does both: #snapshot:andQuit:.

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: Exit loop

Javier Reyes-2
Hi Bert,

Thanks for the explanation. Now its cristal clear to me.

All the best,
                     Javier

On 10/8/07, Bert Freudenberg <[hidden email]> wrote:

On Oct 8, 2007, at 0:30 , Javier Reyes wrote:

> Hello All,
>
> I am trying to create a button or morph that when pressed stores
> the present Squeak image and exits Squeak. I have tried both with a
> PluggableButtonMorph with its action associated and with a plain
> rectangleMorph defining its mouseDown method as follows:
>
> mouseDown: anEvent
> SmalltalkImage current saveImageInFileNamed: (SmalltalkImage
> current imageName).
> Smalltalk quitPrimitive.
>
>
> In both cases pressing the morph performs as expected, but when I
> try to launch that image back and the application with it, it seems
> to be looped into that event again exiting immediately.
>
> I know I am missing something important.  Could someone explain me
> what it is ?

Sure.  "Saving" an image means simply to stop time. So time stops
"inside" of #saveImageInFileNamed:, and when you resume the image,
the first thing it executes is ... quitPrimitive. That's why we have
that method that does both: #snapshot:andQuit:.

- Bert -