Android Question DraggableView class Get views position on screen

Discussion in 'Android Questions' started by apty, Nov 25, 2017.

  1. apty

    apty Active Member Licensed User

    I am using draggable view class to move some buttons on screen. How can i get the view's (button's) position on screen (the left and top position) on my device.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Button.Left / Top will return the current position. The new view is added above the original view.
     
  3. apty

    apty Active Member Licensed User

    thanks Erel,
    in my case, i would like to know the position of the button that has been dragged, just like in b4a visual designer. If i have 3 buttons, i drag the first one and drop it at let say position X( X representing the top position). i then drag button 2 to another position X2. I then have a textbox that traces the position of the button being dragged, the textbox changes its value according to the current button i am dragging. Now my problem is, how do i get the position of the current button i have just clicked on an dragged? noting that all buttons are draggable
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Raise an event when Action = ACTION_UP and then check the position of the owned view.
     
  5. apty

    apty Active Member Licensed User

    Thanks a lot. That works
     
  6. apty

    apty Active Member Licensed User

    Now another headache is caching the click event of the button. I have added onclicklistener to the panel in draggableview class but i am not able to catch it as shown below:

    on Initialize of draggableview
    Code:
    r.SetOnClickListener("Panel1_Click")
    Then
    Code:
    Sub Panel1_Click

        CallSubDelayed(Main,
    "checkclick")
    End Sub
    Then on main

    Code:
    Sub checkclick
        
    Msgbox(btn.Tag,"Tag")
    End Sub
     
  7. apty

    apty Active Member Licensed User

    solved. i noted i could do it in ACTION_UP
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice