links to this page:    
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
What does a Menu Item Do?
Last updated at 11:20 pm UTC on 6 June 2018

The Problem

I found that I wanted to file in some .ST and .CS files under my own program control. So I asked myself "How does the file browser do it?

A Solution

After poking around with Morphic for a while and reading the "white" Squeak book (See Smalltalk & Squeak books ), I stumbled upon a useful way to find out what a menu item executes.

1. Get to the menu item you want.
highlight it.
Do not click it.
In this example, I selected a .ST file and right clicked to
get the menu. Then I tapped the down arrow key to highlight
the "file in entire file" item.

2. Bring up the halos (center mouse button/wheel for windows) and keep clicking over the menu item until you get just the highlighted MenuItem with halos around it like this.

Uploaded Image: P34401.gif

Now use the wrench item on the right side with a left click and inspect the morph. As you look at the instance variables, you will find the interesting target and selector members. The value of target is shown here

Uploaded Image: P34402.gif

Now, using the browse implementers of the interesting fileIn: method reveals two implementers as shown below.

Studying the selector instance variable, we see it is using a method called #performServiceFor: that takes the target string and decodes it into fileIn: method. The arguments instance variable turns out to be the name of the file selected in the fileList. Hmmm... This is starting to make sense. Now, who implements the fileIn: method?

Uploaded Image: P34403.gif

The class side of the FileStream seems to have what we need. So to programatically file in something, we could execute:

FileStream fileIn: 'MyChangeset.cs'

Note that not all menu items give up their secrets so easily. You have to look through interfacing methods. Using this technique is useful for finding a good starting place.