ListViewGadget + Drag & Drop (?)

Just starting out? Need help? Post your questions and find answers here.
AZJIO
Addict
Addict
Posts: 1312
Joined: Sun May 14, 2017 1:48 am

ListViewGadget + Drag & Drop (?)

Post by AZJIO »

I need to drag the item so that it appears where the cursor is (Windows, Linux).

Code: Select all

EnableExplicit

#Window = 0

Enumeration
	#SourcePrivate
EndEnumeration

Define tmp$, tmp, ind, i


If OpenWindow(#Window, 0, 0, 760, 520, "Drag & Drop", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
	ListViewGadget(#SourcePrivate,   10, 10, 740, 500)

	For i = 1 To 9
		AddGadgetItem(#SourcePrivate, -1, "item " + Str(i))
	Next
	;
	EnableGadgetDrop(#SourcePrivate, #PB_Drop_Private, #PB_Drag_Copy, 2)
	
	Repeat
		Select WaitWindowEvent()
			Case #PB_Event_Gadget  
				If EventType() = #PB_EventType_DragStart
					Select EventGadget()
						Case #SourcePrivate
							ind = GetGadgetState(#SourcePrivate)
							tmp$ = GetGadgetText(#SourcePrivate)
							DragPrivate(2) ;  EnableGadgetDrop ... 2
					EndSelect
				EndIf
			Case #PB_Event_GadgetDrop
				Select EventGadget()
					Case #SourcePrivate
						RemoveGadgetItem(#SourcePrivate, ind)
						AddGadgetItem(#SourcePrivate, -1, tmp$)
				EndSelect
			Case #PB_Event_CloseWindow
				End
		EndSelect
		
	ForEver
EndIf
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: ListViewGadget + Drag & Drop (?)

Post by infratec »

Code: Select all

AddGadgetItem(#SourcePrivate, GetGadgetState(#SourcePrivate), tmp$)
Post Reply