B4J Library [B4A] [XUI] SD: XUI_DragView

This library handles drag and drop of XUI views.
It is a simple library with few methods but it only serves to drag the space already indicated.
(required XUI 1.72+)

Good fun

SD_XUI_DragView

Author:
Star-Dust
Version: 0.03
  • DragDropView
    • Events:
      • DragViewMoving (DragView As B4XView)
      • PlacedCoordinate (DragView As B4XView)
      • PlacedView (DragView As B4XView, PlaceView As B4XView)
    • Fields:
      • OverPlaceMoreView As Boolean
    • Functions:
      • AddDragView (View As B4XView, AddAlsoPlaceCoordinate As Boolean) As DragDropView
        View is mobible View (Label,Panel ecc..)
        AddAlsoPlaceCoordinate (boolean) Add Initial View Coordinate to AddPlaceCoordinate
      • AddPlaceCoordinate (Left As Int, Top As Int, Width As Int, Height As Int) As DragDropView
      • AddPlaceView (View As B4XView) As DragDropView
      • Class_Globals As String
      • ClearDrag As String
      • ClearPlaceCoordinate As String
      • ClearPlaceView As String
      • Initialize (mCallBack As Object, mEventName As String) As String
        Initializes the object. You can add parameters to this method if needed.
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
  • DragLabel
    • Events:
      • BoardMoved
      • ClickAddElement (ColumnName As String)
      • ClickModifyColumn (ColumnPosition As Int)
      • ClickModifyElement (ColumnPosition As Int, ItemPosition As Int)
      • ItemClickRightMenu (Position As Int, Value As Object)
    • Fields:
      • BoardBackGroundColor As Int
      • LabelSingleLine As Boolean
      • SpaceBetweenBoard As Int
      • SpaceBetweenColumn As Int
      • SpaceBetweenTitleColumn As Int
    • Functions:
      • AddColumnEmpty (ColumnName As String, Movible As Boolean) As Boolean
        Add a column empy
      • AddColumnList (ColumnName As String, ColumnList As List, TextColor As Int, Movible As Boolean) As Boolean
        Add a entire list - don't isert a duplicate Name
        ColumnName= Colum Title
        ColumnList = List of String
      • AddElement (ColumnName As String, Item As String, ID As String, TextColor As Int, RefreshView As Boolean) As String
        Add a sigle element on column, if column don't exist create it
      • AddElementTo (ColumnPos As Int, Item As String, ID As String, TextColor As Int, RefreshView As Boolean) As String
        Add a sigle element on column, Column select with position
      • AddItemRightMenu (Text1 As String, Text2 As String, Bitmap As Bitmap, ReturnValue As Object) As String
      • Class_Globals As String
      • Clear As String
      • ClearRightMenu As String
      • DesignerCreateView (Base As Object, Lbl As Label, Props As Map) As String
        Base type must be Object
      • GetBase As Panel
      • getID (ColumnPos As Int, ItemPos As Int) As String
        Retun ID List from Column position and Row (Item) position
      • getItem (ColumnPos As Int, ItemPos As Int) As String
        Retun Item List from Column position and Row (Item) position
      • Height As Int
      • Initialize (vCallBack As Object, vEventName As String) As String
      • Invalidate As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • LeftPanelAddElement (ColumnName As String, Item As String) As String
      • LeftPanelClear As String
      • LeftPanelGetColumn As List
      • LeftPanelGetListElement (ColumnName As String) As List
      • LeftPanelRemoveColumn (ColumnName As String) As String
      • LeftPanelRemoveElement (ColumnName As String, Item As String) As String
      • RemoveColumn (ColumnName As String) As Boolean
        Remove entire column
      • RemoveColumnFromPosition (ColumnPosition As Int) As String
        ColumnNumber = 0... n
      • RemoveElelentFromPosition (ColumnPosition As Int, ItemPosition As Int) As Boolean
        Delete a sigle item on coumn from position
      • RemoveElement (ColumnName As String, Item As String) As Boolean
        Delete a sigle item on coumn
      • SetBoardToHome As String
      • SetDimension (WidthItem As Int, HeightItem As Int) As String
        Width >=50dip
        Height >=20dip
      • SetMovibleColumn (ColumnName As String, Movible As Boolean) As String
      • SortColumn (ColumnName As String, Ascending As Boolean) As String
      • SortColumnFromPosition (ColumnPosition As String, Ascending As Boolean) As String
        ColumnPositione = 0 .. n
      • Width As Int
    • Properties:
      • ColumNameList As List [read only]
        Retun List of Column Title
      • TitleBackgroundColor
        Set Title BackGround Color
      • TitleTextColor
        Set Title Text Color
  • TLeft
    • Fields:
      • Column As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • Item As String
    • Functions:
      • Initialize
        Inizializza i campi al loro valore predefinito.



video1.gif

-
 

Attachments

  • B4A DragView Sample2.zip
    9.6 KB · Views: 367
  • B4A DragView Sample1.zip
    156.8 KB · Views: 353
  • B4J DragView Sample1.zip
    149.8 KB · Views: 349
  • SD_XUI_DragView 0.03.zip
    23.9 KB · Views: 12
  • jSD_XUI_DragView 0.03.zip
    23.7 KB · Views: 11
Last edited:

Magma

Well-Known Member
Licensed User
@Star-Dust ... yes but when i drag (the same moment show the places for drop) ---- not when i placed-dropped them...
 

Star-Dust

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

Magma

Well-Known Member
Licensed User

Magma

Well-Known Member
Licensed 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

Well-Known Member
Licensed User
...Sorry... I was wrong... for some reason that sometimes work and sometimes not :-( ...i will search it more...
 

Magma

Well-Known Member
Licensed 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
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

Well-Known Member
Licensed 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
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
 
Top