Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
MorphicModel
Last updated at 8:19 am UTC on 9 May 2018
The MorphicModel class and its subclasses are used to represent structures with state and behavior as well as graphical structure.

A morphicModel is usually the root of a morphic tree depicting its appearance. The tree is constructed concretely by adding its constituent morphs to a world. There are more than 40 subclasses of MorphicModel in the base system which are used to support pluggability and UI widgets for the development environment.

When a part is named in a World, it is given a new slot in the model. An object (morph, widget) will not respond to an event unless it has been sensitized to that event. An object is sensitized by establishing handlers for events and callbacks (if necessary). When a part is sensitized, it is named, and a set of mouse-driven methods is also generated in the model (what methods do this?). These may be edited to induce particular behavior. When a variable is added through the morphic world, it is given a slot in the model, along with a set of access methods.

In addition for public variables (and this is the default for now), methods are generated and called in any outer model in which this model gets embedded, thus propagating variable changes outward.

The MorphicModel of a PasteUpMorph (e.g. the world morph)

 PasteUpMorph
model
	"Return the model object for this world. If the world has no model, then create one."

	self createCustomModel.
	^ model



createCustomModel
	"Create a model object for this world if it does not yet have one. 
         A model object is an initially empty subclass of MorphicModel. 
         As the user names parts and adds behavior, instance variables and methods are added to this class."

	model isNil ifFalse: [^self].
	model := MorphicModel newSubclass new


See also

MorphicModel subclasses