B4J Library [B4A] [XUI] SD: XUI_DragView

Star-Dust

Expert
Licensed User
Longtime User
i will see if it is a simple thing to implement i will add it in the next update
 

Magma

Expert
Licensed User
Longtime User
Found a little complicated solution - so there is no need for that to update anything...

For helping others too... i am attaching here the code:
B4X:
Private Sub Label1_MousePressed (EventData As MouseEvent)
    If EventData.PrimaryButtonDown=True Then
        DD.AddDragView(Label1,False)
        Pane1.SetColorAndBorder(xui.Color_Green,1,xui.Color_Green,0)
    End If
End Sub

So if label1 clicked and is the "right" label (player-attacker) that i wanna move then make him draggable (DD.AddDragView...) and show where to leave...

so for multiple "objects" can use the following:
B4X:
Private Sub players_MousePressed (EventData As MouseEvent)
    Dim a1 As B4XView=Sender

    If EventData.PrimaryButtonDown=True Then
        Log(a1.tag)
        if a1.tag="1" then         'specific only tag with number 1 !
        DD.AddDragView(players(a1.TAG),False)
        Pane1.SetColorAndBorder(xui.Color_Green,1,xui.Color_Green,0)
        end if
    End If
End Sub
 
Last edited:

Magma

Expert
Licensed User
Longtime User
@Star-Dust

Sorry again...

I am trying to figure how exactly works the ClearPlaceView and ClearDrag....

As i can understand dd.cleardrag will clear all drag... so no drag will work ?
As i can understand dd.clearplaceview will clear all drop... so no drop to a place will work ?

Can i have an example how i will clear all drags and places ?

Thank in advance.
 

Star-Dust

Expert
Licensed User
Longtime User
ClearPlace clears the list of places you set up as landing areas
ClearDrag will clear the list of views you have set as draggable
 

Magma

Expert
Licensed User
Longtime User
ClearPlace clears the list of places you set up as landing areas
ClearDrag will clear the list of views you have set as draggable

Yes I thought that will be like that... but... at B4J

for example - if create a button at your uploaded source code example and put into it that:

B4X:
Private Sub Button1_Click
    DD.ClearPlaceView  'Clearing the places... so can't drop anything to them (but... will give error - if i just drarg n drop here...
    Sleep(0)                    'for some reason if not have it will have error at runtime...
    DD.ClearDrag          'Lets clear the drags... so nothing can drag... but for some reason can drag any label...
    Sleep(0)                    'for some reason if not have it will have error at runtime...
    DD.AddDragView(Label1,False)  '....hey can drag anything
    Sleep(0) '...
    DD.AddPlaceView(Place2) 'this seems works (can't drop anything...) + otheres places give error...
    Sleep(0)
End Sub

:-(
 

Star-Dust

Expert
Licensed User
Longtime User
Update 0.03
  • Add event DragViewMoving (DragView As B4XView)
    This event is raised when a draggable view begins to be dragged

B4X:
Private Sub DD_DragViewMoving(DragView As B4XView)
    Log("Moved: " & DragView.Tag)
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…