Re-doing Morphic ( Was: Re: Traits prototype image )

Andreas Raab andreas.raab at
Tue Feb 11 14:45:45 UTC 2003


> You don't even need the "equal" part of "separate but equal". 
> Imagine a NewMorph as different as you like. Install trial 
> versions of the NewMorphs in a NewWorldMorph. NewWorldMorph 
> would be a bit special, appearing to its owner as a simple 
> childless morph, but to its newSubmorphs it's a whole new 
> world. NewWorldMorph>>drawOn: could dispatch whatever drawing 
> messages NewMorphs supported and these NewMorphs could 
> interact with their siblings, blissfully unaware of the old 
> morphic world where your browsers and debuggers still live.

Exactly. It has the *huge* advantage that one can concentrate on those
issues that one really cares about without having to bother with building
the entire enchilada of tools first. And it's really simple - all you need
is the following:

-- event handling --

handleEvent: anEvent
	"pass those events that we care about into our own environment"
	| evt |
	(#(mouseDown mouseUp mouseMove
	keyDown keyUp keystroke) includes: anEvent type) ifTrue:[
		"pass them into our own environment"
	^super handleEvent: anEvent

handlerForMouseDown: anEvent
	"answer self so we don't have to implement the entire wantsXYZ

handlesMouseOver: evt
	"answer true"

mouseEnter: evt
	"grab keyboard"
	evt hand newKeyboardFocus: self.

-- drawing --

drawOn: aCanvas
	"draw my own 'display'"
	aCanvas drawImage: myDisplay at: (bounds origin).

That's it. 5 methods all in all. With a morph that does the above you are
completely free to build any environment you want. You will get the events
from morphic and can dispatch appropriately. You can draw onto your own
"display" and do whatever you want in terms of graphics. If you want to
introduce stepping semantics you may also want to add #wantsSteps, #step,
and #stepTime and pass the step into your own environment.

  - Andreas

More information about the Squeak-dev mailing list