[Newbies] Re: How to reopen a collapsed Morph from another Morph?

Fredrik Alink falink at free.fr
Sun Aug 16 15:51:21 UTC 2015

Mateusz Grotek wrote
> Your original morph is still referenced by the variable morph in the  
> code above. collapsedMorph is a CollapsedMorph instance. You just need  
> to keep it until you want to expand it. After expanding you throw it  
> away.
> | originalMorph collapsedMorph |
>    originalMorph := yourMorph. "Your original morph is always here. It  
> doesn't turn into a CollapsedMorph."
>    ...
>    ...
>    ...
>    collapsedMorph := morph collapse. "This is the CollapsedMorph. You  
> need to keep it only until expanding."
>    ...
>    ... "You can still use your original Morph available in the variable  
> originalMorph here."
>    ...
>    collapsedMorph collapseOrExpand. "Expanding it. Now you can ignore  
> the collapsedMorph variable."
>    ...

I am trying to understand what you mean. Since I'm talking about 2
concurrent Morphs, I implemented your remarks like this:

MainConsole demoButtonClicked
	morph := ModelConsole new.
	self modelConsole: morph. "handshake"
	collapsedMorph := self myPackageCollapse.
	morph mainConsole: self. "handshake"
	morph collapsedConsole: collapsedMorph. "handshake"

ModelConsole xButtonClicked
	| collapsedMorph expandedMorph |
	"close all running Modelprocessors"
	"	to be defined!	"
	"close own Modelprocessor"
	self mainConsole isNil
		ifFalse: [
			expandedMorph := self mainConsole.
			collapsedMorph := self collapsedConsole.
			"uncollapse MainConsole"
			collapsedMorph collapseOrExpand.
			"release handshakes"
			expandedMorph modelConsole: nil.
			self mainConsole: nil].
	"Close ModelConsole"
	^self currentWorld removeMorph: self

This really solves the problem, *except* for the following situation:
Step 1: open the MainConsole
Step 2: MainConsole > demoButtonClicked: the ModelConsole opens, the
MainConsole collapses
*Step 3*: click on the - sign of the collapsed MainConsole to uncollapse it
*Step 4*: MainConsole > minimizeButtonClicked: to collapse it again
Step 5: ModelConsole > xButtonClicked: the ModelConsole closes, the
MainConsole opens, *but* an artefact of the collapsed MainConsole stays on
the screen.
Step 6: click on the - sign of the artefact and it disappears .....
Step 7: MainConsole > exitButtonClicked: the MainConsole closes.
..... or:
Step 6: MainConsole > exitButtonClicked: the MainConsole closes but the
artefact stays *as active *MainConsole
Step 7: click on the - sign of the collapsed MainConsole to uncollapse it
Step 8: MainConsole > exitButtonClicked: the MainConsole closes.

MainConsole > exitButtonClicked
	^self currentWorld removeMorph: self

MainConsole > minimizeButtonClicked
	^self collapse

So, much better but not perfect ......

View this message in context: http://forum.world.st/How-to-reopen-a-collapsed-Morph-from-another-Morph-tp4842627p4843295.html
Sent from the Squeak - Beginners mailing list archive at Nabble.com.

More information about the Beginners mailing list