Methods that add or remove menus
The methods you use include the following:
addTranscriptMenuNamed: name title: title selectorForBuild: selector before: otherName
Adds the specified menu to the Transcript menus, to the left of the menu specified by otherName. If a menu with the same name already exists, it modifies its title and build selector. If no menu exists for otherName, it adds the specified menu to the leftmost (first) menu position.
This method must be called by the loaded method of an application. The application must also call removeTranscriptMenuNamed: in the application's removing method. Any application that wants to add options to the named menu must implement the method specified by selector. The menu is obtained using transcriptMenuNamed:.
addTranscriptMenuNamed: name title: title selectorForBuild: selector after: otherName
This method is similar to the first but adds the new menu to the right of the menu specified by otherName. If no menu exists for otherName, it adds the specified menu to the rightmost (last) menu position.
removeTranscriptMenuNamed: name
Removes the Transcript menu with the given name. It reports an error if the menu does not exist.
removeTranscriptMenuNamed: name ifAbsent: aBlock.
Removes the Transcript menu with the given name. If the menu does not exist, it evaluates aBlock.
includesTranscriptMenuNamed: name
Answers whether the Transcript menu with the given name exists.
transcriptMenuNamed: name
Answers the Transcript menu with the given name. If the menu does not exist, it answers an empty menu.
Example: Adding a Transcript menu
The following is an example of how a class typically adds a pulldown menu to the Transcript menu bar, and adds some options to the new menu. This example also shows which methods should be used for this code.
A class named MyClass wants to add a menu item named MyApplication to the end of the Transcript menu bar when the class is loaded. If the class is unloaded, the menu is no longer needed. For information on the loaded and removing initialization methods, see Application initialization.
The three class methods of MyClass are the following:
loaded
"Add myMenu to the Transcript when I load."
System
addTranscriptMenuNamed: #myMenu
title: 'MyApplication'
selectorForBuild: #addToMyMenu
after: nil.
removing
"Remove myMenu from the Transcript when I unload."
System removeTranscriptMenuNamed: #myMenu.
addToMyMenu
"Add some items to myMenu"
(System transcriptMenuNamed: #myMenu)
add: #myFirstCommand label: 'Do This';
add: #mySecondCommand label: 'Do That'.
Last modified date: 01/29/2015