Created
September 14, 2016 11:19
-
-
Save peteruhnak/a63e037ae31f6566e61b0c376b256275 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
v := RTView new. | |
"o := TRAnnouncingOverseer new. | |
v canvas eventOverseer: o. | |
o announcer inspect." | |
droppable := RTBox new | |
size: 300; | |
borderColor: Color black; | |
elementOn: 'drop here'. | |
draggable := RTEllipse new | |
size: 60; | |
borderColor: Color black; | |
elementOn: 'drag me'. | |
v add: droppable; add: draggable. | |
draggable translateBy: -400 @ -200. | |
draggable @ RTDraggable. | |
droppable @ (RTLabeled new center color: Color black). | |
draggable @ (RTLabeled new center color: Color black). | |
entered := false. | |
draggable when: TRMouseDragging do: [ :evt | | |
entered | |
ifTrue: [ | |
(droppable encompassingRectangle containsPoint: draggable position) ifFalse: [ | |
entered := false. | |
droppable shape color: Color veryVeryLightGray. | |
droppable update; signalUpdate. | |
] | |
] | |
ifFalse: [ | |
(droppable encompassingRectangle containsPoint: draggable position) ifTrue: [ | |
entered := true. | |
droppable shape color: Color yellow. | |
droppable update; signalUpdate. | |
] | |
] | |
]. | |
v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment