Hello all,
I have studied formbuilder project and interested in CLVDragger.bas . I have tried to code a new project in B4XPages which is attached.
I have 2 problems
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
And another problem when I tested in B4J ,Why it can not be swapped correctly.
			
			I have studied formbuilder project and interested in CLVDragger.bas . I have tried to code a new project in B4XPages which is attached.
I have 2 problems
			
				B4X:
			
		
		
		#If B4J 
Private Sub Drag_MousePressed (EventData As MouseEvent)
#Else
       ???
#End If
    Dim lbl As B4XView = Sender
    Dim list As CustomListView = lbl.Tag
    Dim pnl As B4XView = list.GetPanel(list.GetItemFromView(lbl)).Parent
    pnl.GetView(0).SetColorAndBorder(xui.Color_Transparent, 3dip, 0xFF503ACD, 0)
    Dim ListStartY As Int = EventData.Y + lbl.Top + pnl.Top
    pnl.BringToFront
    Dim Top As Int = pnl.Top
    Do While True
     #If B4J
        Wait For (lbl) Drag_MouseDragged (EventData As MouseEvent)
     #Else
           ???
     #End If
        If pnl.Top < list.sv.ScrollViewOffsetY Then
            list.sv.ScrollViewOffsetY = Max(0, list.sv.ScrollViewOffsetY - 10dip)
        Else If list.sv.ScrollViewOffsetY + list.sv.Height < pnl.Top + pnl.Height Then
            list.sv.ScrollViewOffsetY = list.sv.ScrollViewOffsetY + 10dip
        End If
        Dim ListY As Int = EventData.Y + lbl.Top + pnl.Top
        Dim delta As Int = ListY - ListStartY
        pnl.Top = Top + delta
    Loop
End Sub
#If B4J
Private Sub Drag_MouseReleased (EventData As MouseEvent)
#Else
     ???
#End If
    Dim lbl As B4XView = Sender
    Dim list As CustomListView = lbl.Tag
    Dim index As Int = list.GetItemFromView(lbl)
    Dim pnl As B4XView = list.GetPanel(index).Parent
    Dim Offset As Int = pnl.Top + pnl.Height / 2
    Dim NewIndex As Int = list.FindIndexFromOffset(Offset)
    Dim UnderlyingItem As CLVItem = list.GetRawListItem(NewIndex)
    If Offset - UnderlyingItem.Offset > UnderlyingItem.Size / 2 Then NewIndex = NewIndex + 1
    Dim ActualItem As B4XView = pnl.GetView(0)
    ActualItem.SetColorAndBorder(pnl.Color, 0dip, xui.Color_Black, 0)
    Dim RawItem As CLVItem = list.GetRawListItem(index)
    list.RemoveAt(index)
    If NewIndex > index Then NewIndex = NewIndex - 1
    NewIndex = Max(0, Min(list.Size, NewIndex))
    list.InsertAt(NewIndex, ActualItem, RawItem.Value)
    list.GetRawListItem(NewIndex).TextItem = RawItem.TextItem
End SubAnd another problem when I tested in B4J ,Why it can not be swapped correctly.
Attachments
			
				Last edited: 
			
		
	
								
								
									
	
		
			
		
	
								
							
							 
				 
 
		 
 
		 
 
		 
						
					 
 
		 
 
		