> The second question is: is it possible for element to subscribe for position > updates of another element? (I.e. element A watches for movement of element B > and moves accordingly). I know I could add both of them to a composite shape > or RTGroup (RTDraggable>>groupToDrag:), however I would prefer something more > loosely coupled. > > In RTDraggable>>initializeElement: i found > " element when: TRMouseDragging do: [ :e | e element translateBy: e step. > e signalUpdate ]" > however it is commented out so perhaps there some other way?
Yes you can. Not using events, but Trachel callbacks. Consider the example: -=-=-=-=-=-=-=-=-=-=-=-= | v | v := RTView new. es := RTEllipse elementsOn: Collection withAllSubclasses. v addAll: es. es @ (RTLabelled new text: #numberOfMethods). es @ RTPopup @ RTDraggable. RTMetricNormalizer new elements: es; normalizeSize: #numberOfMethods min: 5 max: 20 using: #sqrt. RTFlowLayout new gapSize: 15; on: es. v -=-=-=-=-=-=-=-=-=-=-=-= When you move a circle, the label moves as well. There is a ‘constraint’ that says the label sticks to the circle The class TRConstraint contains many utility methods you may enjoy to define constraints between elements. For example: TRConstraint class >> stick: aShape onTheTopLeftOf: anotherShape | b | self move: aShape onTheTopLeftOf: anotherShape. b := [ :shape :step | self move: aShape onTheTopLeftOf: anotherShape ]. anotherShape addCallback: (TRTranslationCallback block: b). anotherShape addCallback: (TRExtentCallback block: b) Let us know if you have further question. Cheers, Alexandre