Panel touch event not registering

harlechguy

Member
Licensed User
Longtime User
Hi there, I have a panel - added via the designer on which is placed a scrollview with a child panel (both added at run time)

I would like to use the panel touch event but cannot get a register of the event with either the top level panel (event name set in designer) or the scroll view child (no event name set as if I try to initialize the panel I get a blank panel.

the code is below for both the sub that sets up the scrollview and the panel_touch event - the script works well except for the panel touch element

any ideas appreciated - many thanks

B4X:
Sub updateimage(clickedthumb2a)
Dim tc As ImageView
Dim ths1 As ths
Dim sv1 As ScrollView
Dim pn1 As Panel
Dim cursor1 As Cursor
Dim a1 As Animation
'a1.InitializeAlpha("", 0, 1)
'ToastMessageShow(leftswipe,False)
If leftswipe = True Then a1.InitializeTranslate("", -750dip, 0dip, 0dip, 0dip) ' animate from left
If leftswipe = False Then a1.InitializeTranslate("", 750dip, 0dip, 0dip, 0dip) ' animate from right

a1.Duration = 600

clearpanel2

If minthumb < clickedthumb2 Then 
ImageView4.Visible = True
ImageView4.enabled = True
Else
ImageView4.visible = False
ImageView4.enabled = False
End If
If maxthumb > clickedthumb2 Then
ImageView3.visible = True
ImageView3.enabled = True
Else
ImageView3.visible = False
ImageView3.enabled = False
End If


cursor1 = sql1.ExecQuery2("select Manual, Section, Page, ID from Items where ID= ?", Array As String(clickedthumb2a)) 
cursor1.Position=0
manuala = cursor1.GetString("Manual")
manuala = manuala.Replace(" ","_")
sectiona = cursor1.GetString("Section")
sectiona = sectiona.Replace(" ","_")
page = cursor1.GetString("Page")
page=page.Replace(" ","_")
folderb = manuala & "/" & sectiona & "/" & page & ".jpeg"


ths1.folderb = folderb
ths1.indexb = clickedthumb2a

cursor1.Close

If tc.IsInitialized = True Then tc.RemoveView
sv1.Initialize(1115)
pn1 = sv1.Panel
sv1.BringToFront
pn1.BringToFront



Panel2.AddView(sv1,0,0,750,470)


tc.Initialize("thumbclick")
tc.bitmap= LoadBitmapSample(File.DirRootExternal & "/docbrowser", folderb, 750, 1110)
tc.Gravity=Gravity.FILL
pn1.AddView(tc,5,5,740,1100)
a1.Start(tc)
tc.Tag = ths1
End Sub

B4X:
Sub panel2_Touch (Action As Int, X As Float, Y As Float)
ToastMessageShow("panel touched",False)
If thumbflag = 0 Then Return
   Select Action
      Case Activity.ACTION_DOWN
         startX = X
         startY = Y
      Case Activity.ACTION_UP
         If Abs(Y - startY) > 20%y AND ImageView3.enabled = True Then Return
         If X - startX > 30%x Then
         ImageView3_Click
         Else If startX - X > 30%x AND ImageView4.enabled = True Then
         ImageView4_Click
         End If
   End Select
End Sub
 
Last edited:

harlechguy

Member
Licensed User
Longtime User
Hi Guys, have narrowed down the problem a bit further - any pointers would be appreciated

I have a hierarchy of views as follows

Panel2 = panel
->sv1 = scrollview (sits on panel2)
->pn1 = scrollview panel
->tc = thumbnail (sits in pn1)

I can implement touch events on panel2 - but only responds in areas with no views on top.

I cannot implement touch events on pn1 - in my code pn1 is not initialialised but even when I initialise the

Do scrollview inner panels register touch events?

thanks
 
Upvote 0
Top