Back to using this blog (before I move somewhere else again)!
Let's start with something simple: @GrahamChiu was interested to see how to do drag'n'drop in R3GUI. Here is it:
Let's start with something simple: @GrahamChiu was interested to see how to do drag'n'drop in R3GUI. Here is it:
Some explanation
DRAGGER
is style used for dragging. It's simple box, but you can use anything you want.Dragger / on-click
You need to defineON-CLICK
actor to catch MOUSE-DOWN
event:on-click: [
if arg/type = 'down [
return init-drag face arg/offset
]
]
This will initialize and return the dragging object.Dragger / on-drag
You also need to addON-DRAG
actor to process movement:on-drag: [
face/gob/offset: arg/offset - arg/base
show face/gob
]
Argument for this actor is the drag object defined in ON-CLICK
actor with INIT-DRAG
function.
The drag object holds original position and new offset (and also some other fields that are not interesting for this simple tutorial).Dropper / on-drop
For faces that accept ourDRAGGER
face we need to implement ON-DROP
actor:on-drop: [
append-content face arg/face
return true
]
This actor just adds our DRAGGER
face to target panel and returns TRUE
to indicate everything went well.Notes
If you drop theDRAGGER
on face that has no ON-DROP
defined, DRAGGER
will return to original position automatically.