Hi
I'm trying to use iBarcode library. The example in library ref is working ok but i cant see a preview in my example project with b4xpages. On the other hand the library scans a qr code if i put one in front of camera.
Any idea?
Thank you
I'm trying to use iBarcode library. The example in library ref is working ok but i cant see a preview in my example project with b4xpages. On the other hand the library scans a qr code if i put one in front of camera.
Any idea?
Thank you
main:
#Region Project Attributes
#ApplicationLabel: B4i BarCode
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#Target: iPhone, iPad
#ATSEnabled: True
#MinVersion: 8
#PlistExtra:<key>NSCameraUsageDescription</key><string>Read barcodes</string>
#End Region
B4XMainPage:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Public pgQR As B4XPageBarCode
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
If Not(pgQR.IsInitialized) Then
pgQR.Initialize
B4XPages.AddPage("pgQR", pgQR)
End If
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub Button1_Click
B4XPages.ShowPage("pgQR")
End Sub
B4XPageBarCode:
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Private scanner As BarcodeScanner
Private btnStart, btnStop, btnSave As Button
Private lblResult As Label
Private pnlPreview As B4XView
Private hd As HUD
End Sub
'You can add more parameters here.
Public Sub Initialize As Object
Return Me
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("frmBarCode")
End Sub
Private Sub B4XPage_Appear
scanner.Initialize("scanner", pnlPreview)
btnSave.Enabled = False
lblResult.Text = ""
scanner.Start
Sleep(100)
Dim scanrect As Rect
scanrect.Initialize(50, 10, 250, 210)
scanner.ScanRect = scanrect
End Sub
Sub pnlPreview_Resize (Width As Float, Height As Float)
scanner.Resize
End Sub
Sub scanner_Ready (Success As Boolean)
btnStart.Enabled = Success
' btnStop.Enabled = False
If Success = True Then
hd.ToastMessageShow("Ready to start", False)
Else
hd.ToastMessageShow("Error starting scanner", True)
End If
End Sub
Sub scanner_Detected (Codes As List)
Dim sb As StringBuilder
sb.Initialize
sb.Append("Detected code:").Append(CRLF)
For Each code As BarcodeCode In Codes
sb.Append(code.Value).Append(CRLF)
Next
lblResult.Text = sb.ToString
btnSave.Enabled = True
End Sub
Private Sub btnStart_Click
scanner.Start
Sleep(100)
Dim scanrect As Rect
scanrect.Initialize(50, 10, 250, 210)
scanner.ScanRect = scanrect
hd.ToastMessageShow("Start...", False)
End Sub
Private Sub btnStop_Click
scanner.Stop
hd.ToastMessageShow("Stopping...", False)
End Sub
Private Sub btnSave_Click
hd.ToastMessageShow("Saving...", True)
End Sub