links to this page:    
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How to Study a Menu
Last updated at 4:55 pm UTC on 24 March 2008
From ye juan January 18, 2004 How to study a menu
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 anything useful from it.

How to Study a Menu
Open the World menu, and bring up the halo for the save project on file... menu item (meta-click once to get the menu's halo, and again to get the menu item's halo). You can now inspect the menu item by clicking the light grey debug symbol. The inspect window tells you that:
Locate doMenuItem:with: using the Method Finder tool (you'll find it in the Tools flap). This helps you discover that doMenuItem:with: is a method for TheWorldMenu, and that its definition is:
	TheWorldMenu>>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, when this menu item is selected, this is effectively what happens:
  1. selector := #saveOnFile
  2. nArgs := 0
  3. realTarget := #myWorld
  4. realTarget := myWorld (this object is a PasteUpMorph, and represents your current world view, which comprises all windows that you have open, etc.)
  5. myWorld perform: #saveOnFile (this is Object>>perform, and is equivalent to...)
  6. myWorld saveOnFile (see PasteUpMorph>>saveOnFile)

So, myWorld>>saveOnFile can be called from a program.

Going a bit further, we see that PasteUpMorph>>saveOnFile (for a WorldMorph) executes self project saveAs:
		"Forget where stored before, and store.  Will ask user where."
		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.