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: 825
  • B4A DragView Sample1.zip
    156.8 KB · Views: 775
  • B4J DragView Sample1.zip
    149.8 KB · Views: 775
  • SD_XUI_DragView 0.03.zip
    23.9 KB · Views: 442
  • jSD_XUI_DragView 0.03.zip
    23.7 KB · Views: 407
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
B4X:
Sub Globals
    Dim DD As DragDropView
    
    Private PanelBase As Panel
    Private Label1 As Label
    Private Label2 As Label
    Private Label3 As Label
    Private Label4 As Label
    Private Label5 As Label
    Private Label6 As Label
    
    Private Place1 As Label
    Private Place2 As Label
    Private Place3 As Label
    Private Place4 As Label
    Private Place5 As Label
    Private Place6 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("main")

    DD.Initialize(Me,"DD")
    DD.AddDragView(Label1,False).AddDragView(Label2,False).AddDragView(Label3,False).AddDragView(Label4,False).AddDragView(Label5,False).AddDragView(Label6,False)
    DD.AddPlaceView(Place1).AddPlaceView(Place2).AddPlaceView(Place3).AddPlaceView(Place4).AddPlaceView(Place5).AddPlaceView(Place6)
End Sub

Sub DD_Placed(DragView As View, PlaceView As View)
    Log(DragView.Tag & " - " & PlaceView.Tag)
End Sub
 

sz4t4n

Member
Licensed User
Longtime User
Hi

one question -> how to avoid disappearing view after clicking on it?

video2.gif
 

Star-Dust

Expert
Licensed User
Longtime User

sz4t4n

Member
Licensed User
Longtime User
But if You click on the label (just click not drag) nothing happens? In my case view (which is dragable) just dissapear after mouse click. I used your sample.
 

Star-Dust

Expert
Licensed User
Longtime User
But if You click on the label (just click not drag) nothing happens? In my case view (which is dragable) just dissapear after mouse click. I used your sample.
Ok, I'll see you in the afternoon and I'll release an update
 

Star-Dust

Expert
Licensed User
Longtime User
Update to rel. 0.02 (fix Bugs)
 

Star-Dust

Expert
Licensed User
Longtime User
Hi Peter,
simply because it is more required on mobile devices to drag with your finger.
For Desktop, drag and drop exists in many libraries and was not required of me. I personally don't use it for my apps
 

Star-Dust

Expert
Licensed User
Longtime User
Ops. I was wrong. There is no reason, but I have few requests for B4i and therefore I work less on it
 

Star-Dust

Expert
Licensed User
Longtime User
Ho,
In this library no. But you can do it with the SD_XuiView library, you can turn on panel navigation, so you can drag anywhere
 

redoctober57

New Member
Hi Star-Dust, apologies for a rookie question. I try to run your XUI_DragDrop code. I've downloaded "jSD_XUI_DragView 0.02" library to "AdditionalLibraries\B4J" folder, pointed the Additional Libraries path (in Tools - Configure Paths) to "C:\AdditionalLibraries". I got a compilation error (Dim DD As DragDropView: Unknown type: dragdropview). The "jSD_XUI_DragView 0.02" library does not seem to be imported. I don't see it listed in "Libraries Manager". Can you point out what I did wrong? Thanks!
 

Magma

Expert
Licensed User
Longtime User
Hi...

is there any "event" when i just drag beforce placed anywhere ?

For example if you have 1 player that is good only for attack - when i drag i want to show only placeholder or placeholders for attack...

because DD_PlacedView / returns values when only placed/dropped...
 

Star-Dust

Expert
Licensed User
Longtime User
I don't know if I understand correctly. But you would like some views to be able to position only certain places, while other views may be able to position themselves to other places. And not on any place
 
Top