how to save a project
Ned Konz
ned at squeakland.org
Sun Jan 18 16:56:29 UTC 2004
On Sunday 18 January 2004 5:08 am, ye juan wrote:
> Hi,
> I want to do something about "save a project on
> local file". In the world menu, the selector is
> #saveOnFile, however, I can not get something useful
> from it. So if you know the base, please write to me .
Even better, I will show you how to fish for it:
If you open the World menu, then get a halo on the "save project on file" menu
item, you can then inspect the item.
If you then look at the MenuItemMorph's instance variables, you will see that:
target is TheWorldMorph
selector is #doMenuItem:with:
arguments are #(#(#myWorld #saveOnFile))
And then we look at implementors of doMenuItem:with: and we see that
TheWorldMenu defines this as:
doMenuItem: aCollection with: event
| realTarget selector nArgs |
selector _ aCollection second.
nArgs _ selector numArgs.
realTarget _ aCollection first.
realTarget == #myWorld ifTrue: [realTarget _ myWorld].
realTarget == #myHand ifTrue: [realTarget _ myHand].
realTarget == #myProject ifTrue: [realTarget _ self projectForMyWorld].
^nArgs = 0
ifTrue:[realTarget perform: selector]
ifFalse:[realTarget perform: selector with: event].
So now we know that when this item is selected, this is the equivalent of what
happens:
menu myWorld saveOnFile.
Which is the same as:
ActiveWorld saveOnFile.
since ActiveWorld will be set to the world in which the menu is raised.
So now we can do this from a program.
Going a bit further, we see that PasteUpMorph>>saveOnFile (for a World)
actually does "self project saveAs", which does this:
self forgetExistingURL.
self storeOnServer.
So you could get the same effect for the current Project by just doing this:
Project current saveAs.
By following the definitions of Project>>storeOnServer further, you will see
how it works.
More information about the Squeak-dev
mailing list
|