[Q][Drag&Drop] Event handling, PolygonMorph, line drawing questions
Bob Arning
arning at charm.net
Mon Apr 24 04:24:49 UTC 2000
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.
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.
! !
More information about the Squeak-dev
mailing list
|