How hard can it possibly be?

By: on August 19, 2005

Using Squeak over recent months, I’ve found myself wanting to move windows back and forth between various projects occasionally. (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.)

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 (on class SystemWindow):

| 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.

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.



  1. kenboogie27 says:

    very nice on another topic sort of , what would happen if you deleted a morph that ran an operation that took alot of cpu, would removing that morph from the world kill that cpu slowdown? your code and presentation is very simple and easy to approach. maybe its a good idea to keep your own list or collection of morphs that you can kill or remove . or do other operations on it. like locking all of them or aligning and such in a script sort of way.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>