I have soem area coordinates Webiview and Panel on Activity.
I want to control "gesture2" when touch only 1 finger on webview. (Panel visible= false)
if webview"gesture2" has a2 finger ,
I change "Panel visible =true" and I want to control "gesture3"
So i cant run.
Sortly;
1 finger >> panel visible=false + gesture2 runs...
2+ finger >> panel visible=true(bringfront) + gesture3 runs...
Code std gesture multitouch example.
I littile change it.
I want to control "gesture2" when touch only 1 finger on webview. (Panel visible= false)
if webview"gesture2" has a2 finger ,
I change "Panel visible =true" and I want to control "gesture3"
So i cant run.
Sortly;
1 finger >> panel visible=false + gesture2 runs...
2+ finger >> panel visible=true(bringfront) + gesture3 runs...
Code std gesture multitouch example.
I littile change it.
B4X:
#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: Multitouch Example
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
'Activity module
Sub Process_Globals
End Sub
Sub Globals
Dim bgd, ust As Panel
Dim G As Gestures
Dim GG As Gestures
Dim GGG As Gestures
Dim Label1 As Label
Dim web As WebView
Dim TouchMap,TouchMap2,TouchMap3 As Map
Type Point(Id As Int, prevX As Int, prevY As Int, Color As Int)
Dim Canvas As Canvas
Dim RowHeight As Int
Dim TextSize As Float
TextSize = 18
Dim TextRect As Rect
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Create a panel and add it to the activity
bgd.Initialize("")
Activity.AddView(bgd, 0, 0, 100%x, 45%y)
Canvas.Initialize(bgd)
'Add a listener for this panel
G.SetOnTouchListener(bgd, "GesturesTouch")
TouchMap.Initialize
Label1.Initialize("Label1")
Activity.AddView(Label1, 0, 45%y, 100%x, 10%y)
Label1.Width=100%x
Label1.Height=20%y
Label1.Color=Colors.Yellow
RowHeight = Canvas.MeasureStringHeight("M", Typeface.DEFAULT, TextSize) + 5dip
TextRect.Initialize(0, 0, 120dip, 20dip + RowHeight * 10)
web.Initialize("")
Activity.AddView(web, 0, 55%y, 100%x, 45%y)
web.LoadUrl("http://www.yahoo.com")
ust.Initialize("")
Activity.AddView(ust, 0, 55%y, 100%x, 45%y)
ust.Color=Colors.ARGB(150,150,100,120)
ust.BringToFront
'web.BringToFront
ust.Visible=False
TouchMap3.Initialize
GGG.SetOnTouchListener(ust, "GesturesTouch3")
Dim r As Reflector
r.Target = web
r.RunMethod2("requestDisallowInterceptTouchEvent", False, "java.lang.boolean")
GG.SetOnTouchListener(web, "GesturesTouch2")
TouchMap2.Initialize
Activity.AddMenuItem("Clear", "mnuClear")
End Sub
Sub mnuClear_Click
Dim r As Rect
r.Initialize(0, 0, 500%x, 100%y)
Canvas.DrawRect(r, Colors.Transparent, True, 0) 'erase everything
bgd.Invalidate
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub GesturesTouch3(View As Object, PointerID As Int, Action As Int, X As Float, Y As Float) As Boolean
Label1.Text="ust panel:"& DateTime.Time(DateTime.Now)
Log("ust::"&DateTime.Time(DateTime.Now))
Dim p As Point
Canvas.DrawRect(TextRect, Colors.Transparent, True, 0)
Dim px, py As Int
Select Action
Case g.ACTION_DOWN, g.ACTION_POINTER_DOWN
'New Point is assigned to the new touch
Log("UST:: DOWN")
p.Id = PointerID
p.Color = Colors.RGB(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255))
TouchMap3.Put(PointerID, p)
Case g.ACTION_POINTER_UP
Log("UST:: P UP")
TouchMap3.Remove(PointerID)
Case g.ACTION_UP
Log("UST:: UP")
'This is the end of this gesture
web.BringToFront
TouchMap3.Clear
End Select
For i = 0 To TouchMap3.Size - 1
p = TouchMap3.GetValueAt(i)
px = g.GetX(p.id)
py = g.GetY(p.id)
Dim s As String
s ="p"& p.Id & ": " & px & " x " & py
Canvas.DrawText(s, 10dip, 20dip + i * RowHeight, Typeface.DEFAULT, TextSize, p.Color, "LEFT")
If p.prevX > 0 And p.prevY > 0 Then
Canvas.DrawLine(p.prevX, p.prevY, px, py, p.Color, 5dip)
End If
p.prevX = px
p.prevY = py
Next
bgd.Invalidate
If TouchMap3.Size<2 Then
Log("UST:: SİZE =" & TouchMap2.Size)
web.BringToFront
ust.Visible=False
Return True
Else
Log("UST:: SİZE =" & TouchMap2.Size)
ust.Visible=True
Return False
End If
End Sub
Sub GesturesTouch2(View As Object, PointerID As Int, Action As Int, X As Float, Y As Float) As Boolean
Log("web::"&DateTime.Time(DateTime.Now))
Label1.Text="web touch-"& DateTime.Time(DateTime.Now)
Dim p As Point
Canvas.DrawRect(TextRect, Colors.Transparent, True, 0)
Dim px, py As Int
Select Action
Case g.ACTION_DOWN, g.ACTION_POINTER_DOWN
'New Point is assigned to the new touch
Log("web:: DOWN")
p.Id = PointerID
p.Color = Colors.RGB(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255))
TouchMap2.Put(PointerID, p)
Case g.ACTION_POINTER_UP
Log("web:: P UP")
TouchMap2.Remove(PointerID)
Case g.ACTION_UP
'This is the end of this gesture
Log("web:: UP")
TouchMap2.Clear
End Select
For i = 0 To TouchMap2.Size - 1
p = TouchMap2.GetValueAt(i)
px = g.GetX(p.id)
py = g.GetY(p.id)
Dim s As String
s ="w"& p.Id & ": " & px & " x " & py
Canvas.DrawText(s, 10dip, 20dip + i * RowHeight, Typeface.DEFAULT, TextSize, p.Color, "LEFT")
If p.prevX > 0 And p.prevY > 0 Then
Canvas.DrawLine(p.prevX, p.prevY, px, py, p.Color, 5dip)
End If
p.prevX = px
p.prevY = py
Next
bgd.Invalidate
If TouchMap2.Size>1 Then
Log("web:: SİZE =" & TouchMap2.Size)
ust.BringToFront
ust.Visible=True
Return True
Else
Log("web:: SİZE =" & TouchMap2.Size)
ust.Visible=False
Return False
End If
End Sub
Sub GesturesTouch(View As Object, PointerID As Int, Action As Int, X As Float, Y As Float) As Boolean
Label1.Text="std"
Dim p As Point
Select Action
Case g.ACTION_DOWN, g.ACTION_POINTER_DOWN
'New Point is assigned to the new touch
p.Id = PointerID
p.Color = Colors.RGB(Rnd(0, 255), Rnd(0, 255), Rnd(0, 255))
TouchMap.Put(PointerID, p)
Case g.ACTION_POINTER_UP
TouchMap.Remove(PointerID)
Case g.ACTION_UP
'This is the end of this gesture
TouchMap.Clear
End Select
'Clear the previous text
Canvas.DrawRect(TextRect, Colors.Transparent, True, 0)
Dim px, py As Int
For i = 0 To TouchMap.Size - 1
p = TouchMap.GetValueAt(i)
px = g.GetX(p.id)
py = g.GetY(p.id)
Dim s As String
s ="s"& p.Id & ": " & px & " x " & py
Canvas.DrawText(s, 10dip, 20dip + i * RowHeight, Typeface.DEFAULT, TextSize, p.Color, "LEFT")
If p.prevX > 0 And p.prevY > 0 Then
Canvas.DrawLine(p.prevX, p.prevY, px, py, p.Color, 5dip)
End If
p.prevX = px
p.prevY = py
Next
bgd.Invalidate
Return True
End Sub
Last edited: