Constraining resize/creation behavior
ned at bike-nomad.com
Wed Nov 19 23:10:28 UTC 2003
On Wednesday 19 November 2003 2:25 pm, Bijan Parsia wrote:
> I want to make a very simple drawing like app wherein I have a background
> image upon which one can draw overlay shapes that delimit regions (for the
> interesting, those regions will be associated with annotations). It seems
> like this should be trivial in Morphic. But I don't quite see how to
> constrain resize/creation behavior of morphs to be within some bounds
> (note that I don't want display clipping behavior a la bookmorphs). Is
> there a simple way to do this? Or a simple right way to do this? I turn to
> you have having slogged though the Morphrass to HandleMorph and
> experiencing that raw fear that the way I'm going at it will require
> touching every class in the image...
I'm not sure what you're asking here.
What exactly are you trying to do?
You can make Morphs with any bounds you like, including ones outside their
You can tell the parents not to clip when drawing if you want.
You could just make all your region shapes submorphs of the World.
Assuming you're not going to use halos to do the resizing (it's probably best
not to use the stock halos at all in a simple app targeted at end users who
aren't doing eToys), resizing is under your control; you would be following
the Hand and resizing/moving the Morph accordingly.
And I understand your fear of HandleMorph, but it's there already, and pretty
much works. You just have to fill in your own code for the resizing.
For instance, here's some code from Connectors that does a modal resizing of a
Morph, snapping to a grid and using the shift key as a request to keep the
"If shift is pressed, force my bounds to be square.
Note that some of the Unix VM's don't report shift state
changes with mouse
moves so this won't work"
| handle hand lastTime |
hand _ evt hand.
lastTime _ Time millisecondClockValue.
handle _ NewHandleMorph new
forEachPointDo: [:newPoint | | newExtent |
Time millisecondClockValue - lastTime > 70
ifTrue: [newExtent _ self griddedPoint: (self globalPointToLocal:
- self fullBounds topLeft.
hand lastEvent shiftPressed
ifTrue: [newExtent _ (newExtent x max: newExtent y) asPoint].
(newExtent x = 0
or: [newExtent y = 0])
ifFalse: [self extent: newExtent].
lastTime _ Time millisecondClockValue ]]
lastPointDo: [:pt | pt]
withCursor: Cursor bottomRight.
hand attachMorph: handle
GPG key ID: BEEA7EFE
More information about the Squeak-dev