Comment #3 on issue 849 by alexandr...(a)gmail.com: Roassal rubber-banding
http://code.google.com/p/moose-technology/issues/detail?id=849
The following scripts seems to do the thing
"Preambule. It includes the initialization. "
| rawView view el1 el2 line tmpElement |
rawView := ROView new.
view := ROMondrianViewBuilder view: rawView.
"enter your script below"
"-------------"
"-------------"
el1 := ROElement new + ROBorder red.
el2 := ROElement new + ROBorder red.
el1 extent: 50 @ 50.
el2 extent: 50 @ 50.
rawView add: el1.
rawView add: el2.
el2 translateTo: 250 @ 80.
el1 on: ROMouseDragging do: [ :event |
| relativePosition |
line ifNil: [
tmpElement := ROElement new.
line := ROEdge lineFrom: event element to: tmpElement.
rawView add: line.
rawView add: tmpElement. ].
relativePosition := rawView camera realToVirtualPoint: (event position).
tmpElement translateTo: (relativePosition ).
rawView signalUpdate
].
el1 on: ROMouseDragged do: [ :event |
| element |
tmpElement remove.
line remove.
line := nil.
tmpElement := nil.
element := (rawView elementAtRealPosition: event position) .
(element isKindOf: ROElement)
ifTrue: [ rawView add: (ROEdge lineFrom: event element to: element )].
rawView signalUpdate.
].
"-------------"
"-------------"
"Below is the initiation of the menu and opening the visualization"
ROEaselMorphic new populateMenuOn: view.
view open