Skip to content

Instantly share code, notes, and snippets.

@peteruhnak
Created September 14, 2016 11:19
Show Gist options
  • Save peteruhnak/a63e037ae31f6566e61b0c376b256275 to your computer and use it in GitHub Desktop.
Save peteruhnak/a63e037ae31f6566e61b0c376b256275 to your computer and use it in GitHub Desktop.
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