[Q][Drag&Drop] Event handling, PolygonMorph, line drawing questions

Stephan Rudlof sr at evolgo.de
Mon Apr 24 16:23:53 UTC 2000


Bob,

Bob Arning wrote:
> 
> On Mon, 24 Apr 2000 04:47:23 +0200 Stephan Rudlof <sr at evolgo.de> wrote:
> >I'm trying to use PolygonMorph (or a similar subclass) to visualize
> >drag&drop operations.
> >I want to have a line from the drag start point following the hand while
> >dragging a Morph to the drop position.
> 
> Stephan,
> 
> Here's a simpler one.

Thank you very much! That's it!

And your second solution is also faster than the first one.

It is - as often - much simpler as I thought.

But in 
Morph>>privateMoveBy: delta 
	"Private! Use 'position:' instead."
...
there is this comment und also it is located in protocol 'private'. It
wasn't obvious for me to look for 'private' methods in Morph or
elsewhere.

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.


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?


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?


Last question:

In
---
LineDrawingMorph>>
justDroppedInto: aMorph event: anEvent
 
         myPolygon ifNotNil: [myPolygon delete. myPolygon _ nil].
         self changed.
---

niling myPolygon isn't necessary, isn't it?


Greetings,

Stephan


> 
> Cheers,
> Bob
> 
> ===== code snippet follows =====
> 'From Squeak2.8alpha of 13 January 2000 [latest update: #2005] on 24 April 2000 at 12:23:59 am'!
> "Change Set:            draglines
> Date:                   24 April 2000
> Author:                 Bob Arning
> 
> A simple morph which, when picked up by the hand, draws a line between its original position and its current position"!
> 
> RectangleMorph subclass: #LineDrawingMorph
>         instanceVariableNames: 'positionWhenPickedUp myPolygon '
>         classVariableNames: ''
>         poolDictionaries: ''
>         category: 'Test-DragAndDrop'!
> 
> !LineDrawingMorph methodsFor: 'as yet unclassified' stamp: 'RAA 4/23/2000 23:38'!
> aboutToBeGrabbedBy: aHand
> 
>         myPolygon _ PolygonMorph
>                 vertices: {self position. self bounds corner}
>                 color: Color red
>                 borderWidth: 1
>                 borderColor: Color blue.
>         World addMorphFront: myPolygon.! !
> 
> !LineDrawingMorph methodsFor: 'as yet unclassified' stamp: 'RAA 4/24/2000 00:04'!
> justDroppedInto: aMorph event: anEvent
> 
>         myPolygon ifNotNil: [myPolygon delete. myPolygon _ nil].
>         self changed.! !
> 
> !LineDrawingMorph methodsFor: 'as yet unclassified' stamp: 'RAA 4/24/2000 00:18'!
> privateMoveBy: delta
> 
>         super privateMoveBy: delta.
>         myPolygon ifNil: [^self].
>         myPolygon vertices at: 2 put: self position.
>         myPolygon computeBounds.
> ! !

-- 
Stephan Rudlof (sr at evolgo.de)
   "Genius doesn't work on an assembly line basis.
    You can't simply say, 'Today I will be brilliant.'"
    -- Kirk, "The Ultimate Computer", stardate 4731.3





More information about the Squeak-dev mailing list