Sviluppatori Basic (e non) per Mobile e Desktop

Forum dedicato agli sviluppatori di B4X, Delphi, Xamarin


Non sei connesso Connettiti o registrati

EditText con Copy&Paste Fluttuante

Andare in basso  Messaggio [Pagina 1 di 1]

1 EditText con Copy&Paste Fluttuante il Dom Apr 22, 2018 4:57 pm

Dust

avatar
Admin
Admin


Codice:
TT.Initialize(EditText1,Colors.Gray,Colors.Black)

Codice:
Sub Class_Globals
   Dim EditText As EditText
   Private StartX, StartY As Int
   Private LabelMove As Label
   Private ColorLabel As Int
   Private MainPanel As Panel
   
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(E As EditText,Color As Int, TextColor As Int)
   MainPanel = E.Parent
   EditText=E
   ColorLabel=Color
   
   LabelMove.Initialize("LabelMove_Touch")
   LabelMove.Color=Colors.Transparent
   LabelMove.TextColor=TextColor
   MainPanel.AddView(LabelMove,E.Left,E.Top,E.Width,10dip)
         
   Dim R As Reflector
   R.Target=LabelMove
   R.SetOnTouchListener("LabelMove_Touch")
End Sub

Private Sub LabelMove_Touch(viewtag As Object, action As Int, X As Float, Y As Float, motionevent As Object) As Boolean
   Select action
      Case 0 ' Down
         Dim i As IME
         i.Initialize("")
         i.HideKeyboard
         
         StartX=X
         StartY=Y
         LabelMove.Text=EditText.Text
         LabelMove.SetLayout(EditText.Left,EditText.Top,EditText.Width,EditText.Height)
         LabelMove.Color=Bit.And(ColorLabel,0xFFFFFF)+0x55000000
                  
      Case 1 ' UP
                  
         For Each V As View In MainPanel.GetAllViewsRecursive
            If GetType(V)="android.widget.EditText" Then
               If InPlace(LabelMove,V) Then
                  Dim E As EditText = V
                  E.Text=LabelMove.Text
               End If
            End If
         Next
         
         EditText.Width=EditText.Width
         LabelMove.SetLayoutAnimated(100,EditText.Left,EditText.Top,EditText.Width,10dip)
         
         LabelMove.Color=Colors.Transparent
         LabelMove.Text=""
      Case 2 ' move
         LabelMove.Left=LabelMove.Left+X-StartX
         LabelMove.top=LabelMove.top+y-StartY
         LabelMove.Color=ColorLabel
   End Select
      
   Return True
End Sub

Private Sub InPlace(v1 As View,v2 As View) As Boolean
   Dim l1 As Int = v1.Left
   Dim t1 As Int = v1.Top
   Dim w1 As Int = v1.Width
   Dim h1 As Int = v1.Height
   
   Dim l2 As Int = v2.Left
   Dim t2 As Int = v2.Top
   Dim w2 As Int = v2.Width
   Dim h2 As Int = v2.Height
   
   Dim l3 As Int = l1 + w1
   Dim t3 As Int = t1 + h1
   Dim l4 As Int = l2 + w2
   Dim t4 As Int = t2 + h2
   
   If (l1>=l2 And l1<=l4)Or(l3>=l2 And l3<=l4) Then
      If (t1>=t2 And t1<=t4)Or(t3>=t2 And t3<=t4) Then
         Return True
      End If
   End If
   Return False
End Sub

Visualizza il profilo dell'utente http://basic4x.forumattivo.com

Tornare in alto  Messaggio [Pagina 1 di 1]

Permessi di questa sezione del forum:
Non puoi rispondere agli argomenti in questo forum