Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
How do I move a morph from one project to another?
Last updated at 10:27 am UTC on 11 June 2018
Bob Arning
Mon, Apr 30, 2018 at 7:37 PM
To: squeak-dev@lists.squeakfoundation.org

Two options:

1. drop it into a shared flap and take it out on the other project

2. open an explorer on the morph and then
 (Project named: 'whatever') world addMorph: self


Tony Garnock-Jones
Mon, Apr 30, 2018 at 8:14 PM
Reply-To: The general-purpose Squeak developers list

To: The general-purpose Squeak developers list , Chris Cunningham

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:)
http://homepages.kcbbs.gen.nz/tonyg/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

Cheers,
Tony

Here’s the code (on class SystemWindow):

 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.

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.

Stéphane Rollandin
Tue, May 1, 2018 at 3:10 PM
Reply-To: The general-purpose Squeak developers list
To: squeak-dev@lists.squeakfoundation.org
Reply | Reply to all | Forward | Print | Delete | Show original

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





Bob Arning
Wed, May 2, 2018 at 10:25 AM
Reply-To: The general-purpose Squeak developers list
To: squeak-dev@lists.squeakfoundation.org


Sounds to me like the discussion has moved into the it-could-mean-just-about-anything stage. So far we have:
  • sending morphs from one project to another
  • perhaps selecting the destination based on some morph property
  • perhaps the receiving project could refuse to accept the morph
  • make the morph frontmost in the receiving project's world, unless that project doesn't even have a world

And other questions occur:

  • why limit this to morphs? Why not send arbitrary data from project to project?
  • is a morph a ui representation of some separate domain object? Where does the domain object live?
  • what if the sending project is in "grid-view mode" and the receiving project is in "list-view mode"? Does sending a specific morph make any sense?
  • why assume the morph would be installed in the world at the other end?
  • do we assume the morph must be deleted from the sending world? Dropping a morph on a PVM will send a copy to the other project.

This all started with a simple problem that had a simple answer. Then many answers appeared without a clear notion of what the problem is. Who has a real problem that happens several times a day that takes too long to do? DTSTTCPW, anyone?

DropZoneMorph allows to send a morph to another project.
See also EToyProjectHistoryMorph.