B4J Question ABMaterial b4j_raiseEvent - can javascript be paused until it completes?

JackKirk

Well-Known Member
Licensed User
Longtime User
I am having massive fun playing around with ABMaterial.

I have some javascript in my camera code that goes something like:
B4X:
            var cam_click = document.getElementById('cam_click');
            cam_click.play();
            var cam_canvas = document.getElementById('cam_canvas');
            var cam_context = cam_canvas.getContext('2d');
            cam_canvas.width = camVideo.videoWidth;
            cam_canvas.height = camVideo.videoHeight;
            cam_context.drawImage(camvideo, 0, 0, camVideo.videoWidth, camVideo.videoHeight);
            var cam_dataURL = cam_canvas.toDataURL('image/jpg');

            divCam.style.display = 'none';
            divLogo.style.display = 'block';
            divUploadingMsg.style.display = 'block';

            b4j_raiseEvent('${Passed_Instance_Name}_PictureTaken', {'value': sps_deeplink_acc_guid + '>>' + cam_dataURL});

            divAnalysingMsg.style.display = 'block';
The divUploadingMsg is just a message that says "Uploading to cloud..." which is what the b4j_raiseEvent('${Passed_Instance_Name}_PictureTaken', code actually does.

The divAnalysingMsg is just a message that says "Analysing in cloud..." which is what is supposed to happen after the picture is uploaded.

There should be a short pause between these messages while the picture is uploaded - which is not happening because the B4J code fired by b4j_raiseEvent('${Passed_Instance_Name}_PictureTaken' appears to run in parallel to the javascript.

Is there any way I can make the javascript pause until the B4J code is finished?
 
Top