Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How to add a menu entry to send a SystemWindow to another project
Last updated at 1:19 pm UTC on 5 April 2019
Text content mirrored from Tony Garnock-Jones
https://leastfixedpoint.com/tonyg/kcbbs/lshift_archive/how-hard-can-it-possibly-be-20050819.html and slightly adapted.


Using Squeak over recent months, I’ve found myself wanting to move windows back and forth between various projects [1] occasionally.

Today I decided to try implementing the feature. It turned out to take about 15 minutes: five minutes to conduct experiments to determine a workable procedure for doing the move, five minutes to actually implement the method on the correct class and hook it into the system menus, and five minutes to mail the changeset to the squeak-dev mailing list.

Here’s the code of a new method to add to the instance side of class SystemWindow (category 'menu'):

 sendToProject
    | pr |
    pr := CustomMenu new addList: (Project hierarchyOfNamesAndProjects); startUp.
    pr ifNil: [^ self]. "Don't do anything if the user cancelled the menu."

    World removeMorph: self.
    pr world addMorph: self.

To use this method it needs to be made available in a menu. Thus change the method #buildWindowMenu from

 buildWindowMenu
	| aMenu |
	aMenu := MenuMorph new defaultTarget: self.
	aMenu add: 'change title...' translated action: #relabel.
	aMenu addLine.
	aMenu add: 'send to back' translated action: #sendToBack.
	aMenu add: 'make next-to-topmost' translated action: #makeSecondTopmost.
	aMenu addLine.
 ....

to
 buildWindowMenu
	| aMenu |
	aMenu := MenuMorph new defaultTarget: self.
	aMenu add: 'change title...' translated action: #relabel.
	aMenu addLine.
	aMenu add: 'send to back' translated action: #sendToBack.
	aMenu add: 'make next-to-topmost' translated action: #makeSecondTopmost.
	aMenu add: 'send window to another project...' translated action: #sendToProject.
	aMenu addLine.
 ...

That prompts the user for a project to send the current window to, removes the current window from the active project, and inserts it into the target project. That’s all there was to it! This simplicity and directness is part of what I like about Squeak.

Cheers,
Tony



[1] (Projects in Squeak are a kind of hierarchical multiple-desktop setup, where subprojects of a project are displayed as thumbnails in little windows on the desktop, which when clicked, enter the displayed subproject. The main desktop menu allows you to navigate among all the projects in the image. This page has more detail on Projects.)

[2] Email to Squeak Mailing list

Hi Chris,

On 04/30/2018 05:44 PM, Chris Cunningham wrote:
> Is there a magic menu item somewhere that I can send a morph to a
> specific project?

I solved part of this in 2005, for SystemWindows only, though I'm sure
it would generalize to other morphs straightforwardly:

- blog post:
http://www.lshift.net/blog/2005/08/19/how-hard-can-it-possibly-be/
(mirror:)
https://leastfixedpoint.com/tonyg/kcbbs/lshift_archive/how-hard-can-it-possibly-be-20050819.html

- squeak-dev posting with changeset:
http://lists.squeakfoundation.org/pipermail/squeak-dev/2005-August/093538.html