B4J Question [ABMaterial] Signature Pad Events

JuliamnHeim

Member
Licensed User
Longtime User
I have built a webapp using abmaterial and I am using the Signature Pad. The problem is that I have no way of knowing if anything has been drawn onto the pad, so if i do a getDrawingURI to upload a blank signature the system does not trigger any event. This means if I pause the page just before getDrawing and the user has not signed the page stays paused. (I unpause when the FileUploaded is triggered). Is there any way of knowing if the user has made any mark on the signature pad or can I insert a dot somewhere to ensure it uploads properly.
Thanks
 

JuliamnHeim

Member
Licensed User
Longtime User
Dim sign1 As ABMSignaturePad
sign1.Initialize(page, "sign1", 640, 360, ABM.COLOR_WHITE, ABM.INTENSITY_NORMAL, ABM.COLOR_BLACK, ABM.INTENSITY_DARKEN2, ABM.ZDEPTH_1)
page.Cell(5,2).AddComponent(sign1)
 
Upvote 0

JuliamnHeim

Member
Licensed User
Longtime User
Here is the code i run for uploading

If allsighed=True Then
Dim sign1 As ABMSignaturePad = page.Cell(5,2).Component("sign1")
SignCounter =SignCounter + 1
Dim thefilename As String="a" & functions.csLeadzero(ws.Session.GetAttribute("CustomerPolicyId"),20) & "Signature1" & SignCounter & ".jpg"
Try
File.Delete( File.DirApp & DownloadFolder ,thefilename)

Catch
Log(LastException)
End Try
page.Pause
Try
sign1.GetDrawingURI(thefilename)
Catch
Log(LastException)
End Try
Else
page.Msgbox2("wronginput", "Please first accept Summary and Infosheet before uploading Signature!", "Error", "OK", "", False, ABM.MSGBOX_TYPE_ERROR, False, ABM.MSGBOX_POS_CENTER_CENTER, "")
End If
 
Upvote 0

JuliamnHeim

Member
Licensed User
Longtime User
ABMUploadHandler does not get called at all if the signature is empty. Is there no way for me to insert a dot someware on the pad so that it can never be empty
 
Upvote 0

JuliamnHeim

Member
Licensed User
Longtime User
the only "Error" I get in Chrome is DevTools failed to load SourceMap: Could not load content for chrome-extension://gighmmpiobklfepjocnamgkkbiglidom/include.preload.js.map: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME

Don't even know what that is
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
No, such events could possible kill your server with making requests. But try this:

Add a new method:
B4X:
Sub IsEmptySignaturePad(id As String) As Boolean
    Dim script As String = $"return signatures['${id.ToLowerCase}'].isEmpty();"$
    Dim future As Future = page.ws.EvalWithResult(script, Null)
    Return future.Value
End Sub

Now when getting the picture:
B4X:
Sub btnGetSign_Clicked(Target As String)   
    If Not(IsEmptySignaturePad("sign1")) Then
        Dim sign1 As ABMSignaturePad = page.Cell(2,1).Component("sign1")
        SignCounter =SignCounter + 1
        sign1.GetDrawingURI("Signature" & SignCounter & ".jpg")   
    Else
        Log("Signature is empty!")
    End If
End Sub

The tricky part is getting the id right. if used in a modal or container, you may have to go into the browser and actually getting the right id (because it will have parent prefixes).

Alwaysbusy
 
Last edited:
Upvote 0
Top