Drag & Drop a view

Status
Not open for further replies.

anth12

Member
Licensed User
Longtime User
:sign0104:

Hi. Im new to B4A, downloaded the trial last week and liked it a lot (bought it the next day)...

Is there any way of dragging & dropping a view e.g. the user presses and holds button1 then slides their finger right the button moves with the finger.

How would i go about recording the cursor position, i know that a touch is a click... however if the finger is held down is there a way of getting the position the finger is held at. or anything similar?

Any help would be greatly appreciated. Thanks, Anthony.
 

Jim Brown

Active Member
Licensed User
Longtime User
Hello anth12

Without testing I don't think there is a way to get the 'touch' point from a GUI element

The way I get around this in my mobile layout designer is to have a transparent panel over the top of the GUI elements. When I touch the display I have call a function to find the view under the X,Y point. Then its a matter of tracking the movement

Example -> Designer example (YouTube video)

The Panel touch sub functions like this:
B4X:
Sub Panel_Touch (Action As Int, X As Float, Y As Float)
   Select Action
      Case Activity.ACTION_DOWN ' user just touched the panel
      Case Activity.ACTION_MOVE ' user moving finger in panel
      Case Activity.ACTION_UP ' user released finger off panel
   End Select
End Sub
 
Upvote 0

javiers

Active Member
Licensed User
Longtime User
I can not see the video...

Hello, I can not see the video. Could you turn it on or give an example of the code?

Thank you.
 
Upvote 0

xpectmore

Member
Licensed User
Longtime User
there is a MISERABLE way to get the 'touch' point from a GUI element..
will work fine if you touch first the background(i used some code from examples LISTED here)
 

Attachments

  • miserabletouch.zip
    8.7 KB · Views: 360
Upvote 0

udg

Expert
Licensed User
Longtime User
Upvote 0

xpectmore

Member
Licensed User
Longtime User
if you read up you can see : "a way to get the 'touch' point from a GUI element.."
thanks for that,i can use that too...

and here the same "way to get the 'touch' point from a GUI element.." using a invisible panel :
 

Attachments

  • invisiblepanelway.zip
    8.9 KB · Views: 293
Upvote 0
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…