Drag & Drop - Different Data Depending on DragID Signature

Is it possible to set the drop ID data differently depending on the drag signature that is applicable to the drag and drop action?

I would like the DROPID to contain some data when dragging to one list and different data when dragging to another list. In other words can I interrogate which dag and drop signature is in use at the point of calling SETDROPID()?

Thanks

You can do all kinds of stuff to accomplish various goals with drag and drop, knowing that you can use multiple dragid and dropid per control and other techniques, but when the questions are so generic that they require someone to write you an example, it just means you get a “Yes” :slight_smile:

I think there is enough info and example code in the help on DragID() DropID() SetDropID() for you to write a simple example/test and work out the right code. You can also search help for those (plus Event:Drag / Event:Drop) and find more help like " How to add Drag and Drop to a List Box"

This topic covers some:

Please make a small example and post it here to help others. This GIST has a “Scratch List” program filled from a Directory() of the Temp folder as a good start for making a test project.

Unfortunately there is no code example or anything in the manuals that I can see that sets the DROPID data based on the DROPID signature in use hence my question.

I have a ListBox with 2 DRAGID signatures, ‘Ticket’ and ‘Order’. When someone drags the data to the other listbox with the DROPID of ‘Order’ I want to fill out the SETDROPID with the ID of the order that is being dragged and when someone drags the data to the alternate list box with the DROPID of ‘Ticket’ I want to fill out the SETDROPID with the ID of the ticket that is being dragged.

How can I do that or is it even possible?

Look at the help on SetDropId()

In Event:Drag (or maybe Event:Dragging) the DragID() contains the first matching ID so you can choose and assign the desired value with SetDropID().

Then Event:Drop occurs so you can get that SetDropID(value) from DropID().

Add debug to those events to know the order and what is in the functions, which can tell you ( [thread] [, control] ) that may help.

It can be confusing that DragID() and DropID() are Control Attributes… and Functions … and deal with IDs and values

I remembered I had a simple Drag and Drop in a Bitmap tool. I changed it to have 2 different Signatures: One for Decimal and One for Hex. I confirmed it worked as I described.

 COMBO(@s255),AT(3,11,247,12),USE(InpStr),...,DROPID('DragBMQ_Decimal')
 COMBO(@s255),AT(40,36,204,12),USE(BopStr),...,DROPID('DragBMQ_Hex')

 LIST,AT(2,84),FULL,USE(?List:BMQ),...,DRAGID('DragBMQ_Decimal','DragBMQ_Hex')

Debug confirms that Event:Drag comes first and in there based on DragID() set either Decimal or Hex in the SetDropID

 OF EVENT:Drag
    DID"=DRAGID(,Cn#) ; DB('EVENT:Drag Cn#='& Cn# &' DragID='& DID" &'  CHOICE(?List:BmQ)=' & CHOICE(?List:BmQ) ) 
    IF DRAGID() THEN 
       GET(BMQ, CHOICE(?List:BmQ)) 
       CASE DRAGID()   !What was Dropped on Decimal or Hex
       OF 'DragBMQ_Decimal' ; SETDROPID( BMQ:DecBm )
       OF 'DragBMQ_Hex'     ; SETDROPID( BMQ:HexBm[1:4] & BMQ:HexBm[6:9] & 'h' )
       ELSE                 ; SETDROPID('Unknown DragID=' & DragID())
       END
       DB('EVENT:Drag   SETDROPID() = ' & DROPID() )
    END

 OF EVENT:Drop
    DoD"=DROPID(,Cn#) ; DB('EVENT:Drop Cn#='& Cn# &' DROPID='& DoD" &'  DRAGID()='& DRAGID() )   
    ChangeAndSelect(FIELD(), DROPID())

Debug shows I first drag and dropped on the top Value Entry that takes Decimal. Second I drag and dropped on the Operand that takes Hex. After the mouse release on the Drop control the first Event is Event:Drag where the DragID tells you the matching ID of the Drop so SetDropID() can be done. Next comes Event:Drop.

DragDropBitMapProject.zip (11.9 KB)