links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How to create a custom world menu for the current project and subprojects.
Last updated at 4:00 am UTC on 16 December 2021
To get a customized world menu for the current project do the following:

1. Create a subclass of the class TheWorldMenu.

 TheWorldMenu subclass: #TheWorldMenu4
 	instanceVariableNames: ''
 	classVariableNames: ''
 	poolDictionaries: ''
 	category: 'MyCustomisations-WorldMenu'

Adapt the subclass TheWorldMenu4 to your needs by overriding methods of the class TheWorldMenu.

2. For the current project set a preference to use the new custom menu

In a workspace set the project preference to use the class TheWorldMenu4 by executing

 Project current projectPreferenceFlagDictionary at: #worldMenuClassSymbol put: #TheWorldMenu4.

Note: You might create a button for this by selecting the code and choosing the menu 'button for it'. Then you can put a clone of this button into a flap and use the button in other projects.

Note: You may check the project preferences by executing
 Project current projectPreferenceFlagDictionary explore

3. Extend method PasteUpMorph buildMenu: evt

Then put
into the search box on the top right of the screen and replace the method from May 2000 in PasteUpMorph

buildWorldMenu: evt
	^(TheWorldMenu new
		world: self
		project: (self project ifNil: [Project current])       "mvc??"
		hand: evt hand) buildWorldMenu.


 buildWorldMenu: evt
 |project worldMenuClassSymbol|

 project := self project ifNil: [Project current]  "mvc??".
 worldMenuClassSymbol := project projectPreferenceFlagDictionary at: #worldMenuClassSymbol ifAbsent: [#TheWorldMenu].

 ^((Smalltalk at:  worldMenuClassSymbol) new
		world: self
		project: project     
		hand: evt hand) buildWorldMenu.

4. The result is a custom world menu

The result is that the current project and all subprojects will use an instance of TheWorldMenu4.
The reason why the subprojects use this new custom menu is because when they are initialized a deep copy of the projectPreferenceFlagDictionary is made.


Add another
to PasteUpMorph, e.g. putUpWorldMenu4:

Then use
 World on: #mouseDown send: #putUpWorldMenu4: to: World