[squeak-dev] How do I move a morph from one project to another?

Stéphane Rollandin lecteur at zogotounga.net
Tue May 1 13:10:25 UTC 2018


> Is there a magic menu item somewhere that I can send a morph to a 
> specific project?

I have that in my muO images (such as the available at 
http://www.zogotounga.net/comp/squeak/muo/muO335.zip), it is an item 
from the red halo handle, "send to project..."

The implementation is


Morph>>sendToAnotherProject

	| target |
	
	target := Project queryProject ifNil: [^ self].
	target world addMorph: self



Project class>>queryProject

	| selection nBack prev |
	
	selection := (Project buildJumpToMenu: CustomMenu new) startUpLeftFlush.

	selection ifNil: [^ nil].
	(selection beginsWith: '%back') ifTrue:
		[nBack := (selection copyFrom: 6 to: selection size) asNumber.
		prev := CurrentProject previousProject.
		1 to: nBack-1 do:
			[:i | prev ifNotNil: [prev := prev previousProject]].
		prev ifNotNil: [^ prev]].
	selection = #parent ifTrue:
		[^ CurrentProject parent].
	^ Project namedWithDepth: selection.



Project class>>buildJumpToMenu: menu

	| listed i  toAdd |
	listed := OrderedCollection with: CurrentProject.
	i := 0.

	CurrentProject isTopProject ifFalse:
		[self	addItem: CurrentProject parent name , ' (parent)'
				toMenu: menu
				selection: #parent
				project: CurrentProject parent.
		  menu addLine].

	(Preferences alphabeticalProjectMenu
			ifTrue:
				[Project allNamesAndProjects]
			ifFalse:
				[Project hierarchyOfNamesAndProjects]) do:

		[:aPair |
			toAdd := aPair last isCurrentProject
				ifTrue:
				  [aPair first, ' (current)']
				ifFalse:
				  [aPair first].
			self	addItem: toAdd
				toMenu: menu
				selection: aPair first
				project: aPair last].
	^ menu



Stef


More information about the Squeak-dev mailing list