[squeak-dev] modifying GUI on the fly

Jon Hylands jon at huv.com
Sat Jul 2 14:20:20 UTC 2011


The way I've done it in the past is to just send #delete to the morph, and
then add a new one in its place.

For instance, in this GUI:

http://www.huv.com/roboMagellan/MissionEditor.jpg

The morph at the bottom right, containing the navigator-specific
information, is removed and replaced any time a new goal is selected, since
each goal has a navigator, and specific navigators have different
information associated with them that must be set...

Here's the method I call to do it:

addNavigatorPanelFor: aNavigator

navigatorMorph isNil
ifFalse: [navigatorMorph delete].

navigatorMorph := AlignmentMorph new
listDirection: #topToBottom;
color: Color white;
vResizing: #shrinkWrap;
hResizing: #shrinkWrap;
cellPositioning: #topLeft;
yourself.

aNavigator notNil
ifTrue: [aNavigator addNavigatorMorphsTo: navigatorMorph for: self].

window
addMorph: navigatorMorph
fullFrame: (LayoutFrame
fractions: (0 at 0 corner: 1 at 1)
offsets: (480 at 285 corner: -5 at -5)).

So, basically, it deletes the old navigator morph, creates a new alignment
morph in its place, and then asks the navigator to add its specific
submorphs to it. Then it finally adds the new alignment morph to the window.

- Jon


On Fri, Jul 1, 2011 at 6:01 PM, Ralph Boland <rpboland at gmail.com> wrote:

> I have constructed a GUI (using Morphic) in which one submorph  M
> needs to have its current submorphs replaced by another set of submorphs.
> In general there are several submorph sets exactly one of which is the set
> of submorphs of  M at any one time and which one is in use is determined by
> user input (say clicking a button).  The submorph sets are not
> necessarily disjoint.
>
> Are there any examples showing how I do this?
> Or is it documented somewhere?
>
> In my case at least  M  itself does not move within my main GUI.
>
> Any help or pointers to where help can be found much appreciated.
>
> Regards,
>
> Ralph Boland
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20110702/c786811d/attachment.htm


More information about the Squeak-dev mailing list