6

I have an application that has it's entire GUI in one Morph. Pharo and Squeak have one window in the host operating system.

Now i want to tie this one Morph to the one Pharo/Squeak window in a way that it fills the whole Pharo/Squeak window, resizes (and updates the Morph's layout), when the Pharo/Squeak window is resized and in a way that there is no (accidental) possibility for the user to access anything beyond that Morph (it is just about usability, not about security, though!).

How can i achieve this?

Helene Bilbo
  • 1,142
  • 7
  • 20

1 Answers1

7

Adjust your morph's bounds in its step method:

step
    (self position = (0 @ 0) and: [self extent = owner extent]) ifFalse: [
        self position: 0 @ 0.
        self extent: owner extent].

You may want to make this conditional on a "deployment" flag, which you only enable when saving the user image. This is for example how Scratch (http://info.scratch.mit.edu/Scratch_1.4_Download) does it.

codefrau
  • 4,583
  • 17
  • 17
  • 1
    isn't it would be better to use layouts? morph hResizing: #spaceFill; vResizing: #spaceFill. ? You could also hook-in directly into #checkForNewScreenSize. See senders/implementors of it. – Igor Stasenko Oct 04 '12 at 14:27
  • 1
    A layout would try to operate on all children of the world. Probably not a good idea. checkForNewScreenSize happens on every display cycle anyway, so is similar to a step method, but you won't have to hard-code it. – codefrau Oct 04 '12 at 15:33