Moving of records inside a List with Drag and Drop

I’ve wrote this decades ago, in my case I’m working with a tree.

  1. On your LIST set the DRAGID and the DROP to include the same ID
    ex: LIST,DRAGID('ThisQ', 'AnotherPlace'),DROPID('ThisQ')

  2. when EVENT() = EVENT:Drag

  ! GET( FromQ, ?List{PROPList:MouseDownRow)  ! see comments below by Jeff Slarve
    GET( FromQ, ?List{PROPList:MouseDownRow + 0)
    SETDROPID( 'PK=' & Q.PK )
  1. when EVENT() = EVENT:Drop
       DropRow = ?List{PROPList:MouseUpRow)
    IF DropRow > RECORDS( FromQ )
       DropRow = RECORDS( FromQ )
    END 
    ?List{PROP:Selected} = DropRow 

    DropString = DropID()
    ! parse DropString to get the PK
    ! make your change in the queue and underlying data
  1. Consider having a checkbox to control if you are allowing dragging
    as it can be easy to for a user to accidentally perform a drag
    When ACCEPTED() = ?UI:CanDrag
    IF UI:CanDrag
         ?List{PROP:DragID, 1} = 'ThisQ'
         ?List{PROP:DragID, 2} = 'AnotherPlace'
    ELSE 
         ?List{PROP:DragID, 1} = '' 
    END