Skip to content

Instantly share code, notes, and snippets.

@Oldes
Last active December 18, 2015 16:03
Show Gist options
  • Save Oldes/5b549aa56391542a9b5d to your computer and use it in GitHub Desktop.
Save Oldes/5b549aa56391542a9b5d to your computer and use it in GitHub Desktop.
Drag and drop issue test
Red [
"Drag and Drop test"
filename: %tb.red
author: "Oldes"
version: 0.6.0
date: "18-Dec-2015"
Needs: 'View
]
system/view/debug?: no
live?: system/view/auto-sync?: no
bring-to-top: func [item /local parent pane] [
if all [
parent: item/parent
block? pane: parent/pane
][
;reverse pane ;<--- it's possible to drag with this
;swap find pane item back tail pane ;<--- it's possible to drag with this
append pane take find pane item ;<--- but not possible to drag with this
show parent
]
]
piece-actors: object [
;-- it looks the on-over event is called too much once clicked on face!
on-over: function [face [object!] event [event!]][
print ["Event over" event/offset event/away?]
]
on-drag-start: func [face [object!] event [event!]][
print ["drag starts at" event/offset face/offset]
bring-to-top face
]
on-drop: function [face [object!] event [event!]][
print ["dropping" event/offset face/offset]
]
]
piece-A: make face! [
type: 'base offset: 100x200 size: 30x30 color: 0.255.0
options: [drag-on: 'down]
actors: piece-actors
]
piece-B: make face! [
type: 'base offset: 200x100 size: 30x30 color: 255.0.0
options: [drag-on: 'down]
actors: piece-actors
]
piece-panel: make face! [
type: 'base
offset: 50x50
color: 0.0.100 ;@@ if I use none here, I see no pieces, is it expected?
size: 300x300
pane: reduce [piece-A piece-B]
]
; Declaring the window
win: make face! [
type: 'window text: "test" offset: 300x200 size: 400x400
pane: reduce [piece-panel]
]
view win
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment