I am working on using drag and drop to move a bookmark into a different folder in My Bookmark Manager. I am making progress, but while examining the DragDrop.pb example, I wonder something.
Is there a specific reason (that I don't yet have understanding for) about how the #PB_Event_GadgetDrop event is not returned by EventType(), like #PB_EventType_DragStart is?
My initial expectation is that both would be part of the #PB_Event_Gadget grouping of events.
Question about Drag and Drop Events
Re: Question about Drag and Drop Events
I'm not sure if I understand the question but it's a window event to say that a gadget got a drop event. So you can use EventGadget() then EventDropType() if it's required before calling EventDropText() or EventDropfiles() or EventDropImage() to get the data
you can also use EventDropType() on a #PB_Event_WindowDrop
Code: Select all
EnableGadgetDrop(#TargetText, #PB_Drop_Text , #PB_Drag_Copy) ; <-- drop text
EnableGadgetDrop(#TargetText, #PB_Drop_Files, #PB_Drag_Copy) ; <---drop files
;....
ElseIf Event = #PB_Event_GadgetDrop
Select EventGadget()
Case #TargetText
Select EventDropType() ;<---- See what the drop event type is
Case #PB_Drop_Text
AddGadgetItem(#TargetText, -1, EventDropText())
Case #PB_Drop_Files
Files$ = EventDropFiles()
Count = CountString(Files$, Chr(10)) + 1
For i = 1 To Count
Debug StringField(Files$, i, Chr(10))
Next i
EndSelect
Re: Question about Drag and Drop Events
That sort of clears it up. Using this terminology what I was wondering is why #PB_Event_GadgetDrop is a Windows event, and not a Gadget event?
I was expecting a sort of "symmetry" where all the drag and drop events would be at the same level in my event loop code. But since #PB_Event_GadgetDrop is a window event and #PB_EventType_DragStart is a gadget event, they aren't.
I am trying to see patterns in the way PureBasic works, and this difference in the event (one is for the window the other is for the gadgets) even though they are both related to drag and drop, stood out to me.
I hope that explains my (wrong) thinking better, and why I was wondering if there is a reason they aren't both Gadget events?
Re: Question about Drag and Drop Events
I always got confused with these things. They might be straightforward, but I use them so rarely, that I forget all these behaviors.
Re: Question about Drag and Drop Events
So, your question is, why not just add a corresponding drop event-type to d&d-enabled gadgets, like #PB_EventType_Drop?susan wrote: Sun Dec 07, 2025 5:41 amI was expecting a sort of "symmetry" where all the drag and drop events would be at the same level in my event loop code. But since #PB_Event_GadgetDrop is a window event and #PB_EventType_DragStart is a gadget event, they aren't.
Firstly, the drag and drop functionality is meant to be system-wide, meaning that any d&d-enabled element should be able to have its content dragged from it, or allow external content to be dropped into it, even between separate and external applications. In such inter-application drops, no gadget events would be triggered.
Therefore, PureBasic coordinates these exchanges with its gadget drop library, which triggers the system-wide #PB_Event_GadgetDrop event.
Hope it clarifies.
Texas Instruments TI-99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too! Please visit my YouTube Channel 
Re: Question about Drag and Drop Events
In PureBasic, all events are passed to the user program via WaitWindowEvent.
This makes it very easy for us to process events (thanks, Fred). Especially with the different operating systems Windows, Linux, macOS.
Fred has thus pre-processed the window, the object (EventGadget, EventMenu, EventTimer) and the event type that is passed on to an event.
Otherwise, we would have to program each OS differently ourselves
- Window Messages
- Linux g_signal_connect
- macOS object delegate
You can see how the internal event system works in PureBasic by looking at the PB function PostEvent.
This makes it very easy for us to process events (thanks, Fred). Especially with the different operating systems Windows, Linux, macOS.
Fred has thus pre-processed the window, the object (EventGadget, EventMenu, EventTimer) and the event type that is passed on to an event.
Otherwise, we would have to program each OS differently ourselves
- Window Messages
- Linux g_signal_connect
- macOS object delegate
You can see how the internal event system works in PureBasic by looking at the PB function PostEvent.
My Projects EventDesigner V3 / ThreadToGUI / OOP-BaseClass / Windows: Module ActiveScript
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
PB v3.30 / v5.75 - OS Mac Mini - VM Window Pro / Linux Ubuntu
Downloads on my OneDrive
Re: Question about Drag and Drop Events
I understand now, thanks. I was too focussed on the gadgets and thinking only the gadgets were capable of drag and drop. But if the app (as a whole) needs to know about a drop action, that makes sense.TI-994A wrote: Sun Dec 07, 2025 11:02 am So, your question is, why not just add a corresponding drop event-type to d&d-enabled gadgets, like #PB_EventType_Drop?
Firstly, the drag and drop functionality is meant to be system-wide, meaning that any d&d-enabled element should be able to have its content dragged from it, or allow external content to be dropped into it, even between separate and external applications. In such inter-application drops, no gadget events would be triggered.
I knew there would be a good reason!



