• Username:

  • Remember my login on this computer
  • Register

R3GUI Drag and Drop

Here some examples of Drag and Drop with R3GUI:

Rebol [
 file: %dragndrop.r3
 title: "DragNdrop example"
 author: "Graham Chiu"
 date: 22-may-2013
 purpose: "show how drag and drop works"

update-field-data: func [arg] [
 set-face offset arg/delta + arg/base
 set-face base arg/base
 set-face delta arg/delta

stylize [
 dragbutton: button [
  about: "draggable button"
  facets: [original-position: none]
  actors: [
   on-click: [; arg: event
    focus face
    ; update info fields at top
    set-face goboff face/gob/offset
    if arg/type = 'down [
     ; save the starting positiong in our custom facet
     set-facet face 'original-position face/gob/offset
     ; return the drag object which is then passed to the on-drag actor
     return init-drag/only face arg/offset
    do-face face
    ; docs says none needs to be returned but seems to work without it
   on-offset: [ ; arg: offset
    if all [arg get-facet face 'original-position] [
     face/gob/offset: arg + get-facet face 'original-position
    on-drag: [; arg: drag-object
     ; update our info fields
     update-field-data arg
     ;show face/gob
     do-actor face 'on-offset arg/delta ; arg/delta + arg/base
     ; update the face to show the new position
     draw-face face
     do-attached face
     do-face face
    on-drop: [	
     print "==========on drop"
     probe arg
view [
 hpanel [
  label "Current: " current: field
  label "Gob Offset: " goboff: field
  label "Offset:" offset: field
  label "Base: " base: field
  label "Delta: " delta: field
 scroll-panel [
  pad 10x200
  button "Where is dragbutton" on-action [set-face current db/gob/offset]
  button "Send Dragbutton to home" on-action [db/gob/offset: 0x0 draw-face  db]
  db: dragbutton "DragMe" options [ show-mode: 'fixed ]