[Q][Drag&Drop] Event handling, PolygonMorph, line drawing questions
Bob Arning
arning at charm.net
Mon Apr 24 17:53:41 UTC 2000
On Mon, 24 Apr 2000 18:23:53 +0200 Stephan Rudlof <sr at evolgo.de> wrote:
>My interpreation of the solution is, that all Morphs are automatically
>updated correctly during an update cycle, if #changed (possibly
>#layoutChanged) is called by some method (here by #computeBounds); and
>event handling refers to the morphs *not attached* by the hand only.
I'm not sure what you mean by "event handling" here. If you mean #drawOn:, then the answer is that the HandMorph will cache an image of whatever it is carrying for performance reasons, *unless* the carried object has translucence, in which case it needs to be explicitly redrawn. If you mean the #mouseEnter type of event, then no, objects in the hand will not see these.
>
>But also there arise new problems - as often, too - ...
>
>
>First question:
>
>If I change method
>---
>aboutToBeGrabbedBy: aHand
> myPolygon _ PolygonMorph
> vertices: {self position. self bounds corner}
> color: Color red
> borderWidth: 1
> borderColor: (Color blue alpha: 0.7).
> World addMorphFront: myPolygon
>---
>by setting border color with an alpha value, updating doesn't work. Is
>this a bug?
It will work if the Display depth is 32. Whether it's a bug or not depends on whether translucency is advertised to work at other depths. Maybe Andreas has an answer to that (for the present or for the future).
>
>Second questions:
>
>To have a datched line: Is it a good idea to implement a PolygonMorph
>with datched borders?
>I think this could be quiet complicated, isn't it?
>Or do you have another idea?
You might be able to get something acceptable by using a Form rather than a color to draw the line. You might also write a variant of FormCanvas>>line:to:width:color: that would flip the color used every few pixels.
>
>Last question:
>
>In
>---
>LineDrawingMorph>>
>justDroppedInto: aMorph event: anEvent
>
> myPolygon ifNotNil: [myPolygon delete. myPolygon _ nil].
> self changed.
>---
>
>niling myPolygon isn't necessary, isn't it?
It was more necessary in an earlier incarnation. Now it saves the unnecessary work of updating the polygon after it has been deleted (if, e.g. the LineDrawingMorph stays alive and gets moved by other means). There is also an unused instance variable which could be removed.
Cheers,
Bob
More information about the Squeak-dev
mailing list
|