modifying GUI on the fly

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

modifying GUI on the fly

Ralph Boland
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

Reply | Threaded
Open this post in threaded view
|

Re: modifying GUI on the fly

Jon Hylands
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:


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@0 corner: 1@1) 
offsets: (480@285 corner: -5@-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 <[hidden email]> 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