Signature box within a scroll view

nicholas.jj.taylor

Member
Licensed User
Longtime User
I have set up a layout within a ScrollView with panels working as signature boxes.


The problem I have is that the scrollview wiggles about as the signature is being read.


Currently, I have a signature being recorded via the following method:

Note: the following code was lifted from the Signature recording tutorial http://www.b4x.com/forum/basic4andr...utorials/9096-signature-capture-tutorial.html

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.

   Type SignatureData (Canvas As Canvas, Panel As Panel, SignatureColor As Int, SignatureWidth As Int)

   Dim PreviousX, PreviousY As Int

   Dim SignatureData as SignatureData

   Dim Canvas as Canvas

   Dim Panel as Panel : ' This view is part of the layout "innerformlayout" i.e. inside the ScrollView

   Dim ScrContent as ScrollView : ' This view is part of the layout "outerformlayout" i.e. The container for the ScrollView

End Sub

B4X:
Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   'Activity.LoadLayout("Layout1")
   
   Activity.LoadLayout("outerformlayout")

   If ScrContent.IsInitialized Then
      ScrContent.Panel.LoadLayout("innerformlayout")

      Canvas.Initialize(Panel)

      SignatureData.Initialize
      SignatureData.Canvas = Canvas
      SignatureData.Panel = Panel
      SignatureData.SignatureColor = 0xFF002F8F
      SignatureData.SignatureWidth = 2dip

   End If


End Sub

B4X:
sub Panel_Touch(Action As Int, X As Float, Y As Float)
   If Action = 0 Then 'A value of 0 in Action means that the mouse is pressed down
      PreviousX = X
      PreviousY = Y
      
   Else
      SignatureData.Canvas.DrawLine(PreviousX, PreviousY, X, Y, SignatureData.SignatureColor, SignatureData.SignatureWidth)
      SignatureData.Panel.Invalidate
      PreviousX = X
      PreviousY = Y
      
   End If

End Sub


The real major problem is that the ScrollView is interfering with the recording of the signature, causing vertical lines to be recorded, instead of the desired signature.

My hope is that the solution will involve locking the scrolling of the ScrollView while the signature panel is being touched, because on top of the interference, the wiggling of the form is unsightly.


How should I approach this problem?


Kind regards,
Nick
 
Last edited:

nicholas.jj.taylor

Member
Licensed User
Longtime User
Upvote 0

nicholas.jj.taylor

Member
Licensed User
Longtime User
Okay, I tried

B4X:
Dim Reflector As Reflector
Reflector.Target = ScrContent
Reflector.RunMethod2("setOverScrollMode", 2, "java.lang.int" )

This atleast stopped the ScrollView scrolling after reaching the foot of inner panel, but the pen still zooms off the bottom of the screen.

:sign0013::sign0104:

Please help me. I don't know what to try next.
 
Upvote 0

Sortec

Member
Licensed User
Longtime User
Bump


I have placed a Panel inside a Scrollview for recording signatures after following the Signature tutorial, but while it works when the panel is a direct child of the Activity, it doesn't work when its inside a scrollview.

What happens is, is that the pen will record the signature properly on the x-axis, but only for as long as the pen doesn't move too much on the y-axis. Moving too much on the y causes the ink to fly off the bottom of the panel.

The ink always flies off the bottom, regardless of whether the pen is moved up or down.


Can anyone help me? I'm really stuck on this. I'd be so grateful for any help.
 
Last edited:
Upvote 0
Top