Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Type PositionData (PressedX As Int, PressedY As Int)
Private Button1 As Button
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
Dim view As B4XView = Button1
view.Rotation = 135
End Sub
Sub Button1_MouseDragged (EventData As MouseEvent)
Dim view As B4XView = Sender
Dim pd As PositionData = view.Tag
Dim event As JavaObject = EventData
Dim ParentX As Int = event.RunMethod("getSceneX",Null) + view.Left
Dim ParentY As Int = event.RunMethod("getSceneY",Null) + view.Top
view.Left = ParentX - pd.PressedX
view.Top = ParentY - pd.PressedY
pd.PressedX = event.RunMethod("getSceneX",Null)
pd.PressedY = event.RunMethod("getSceneY",Null)
End Sub
Sub Button1_MousePressed (EventData As MouseEvent)
Dim view As B4XView = Sender
Dim event As JavaObject = EventData
Dim pd As PositionData
pd.PressedX = event.RunMethod("getSceneX",Null)
pd.PressedY = event.RunMethod("getSceneY",Null)
view.Tag = pd
End Sub