Namespace sap.ndc.BarcodeScannerModule: sap/ndc/BarcodeScanner


TODO: description

As BarcodeScanner is a static class, a jQuery.sap.require("sap.ndc.BarcodeScanner"); statement must be explicitly executed before the class can be used. Example: *

jQuery.sap.require("sap.ndc.BarcodeScanner");
sap.ndc.BarcodeScanner.scan(
    function (oResult) { / * process scan result * / },
    function (oError) { / * handle scan error * / },
    function (oResult) { / * handle input dialog change * / }
);


Since: 1.28.0.
Method Summary
sap.ndc.BarcodeScanner.closeScanDialog()Closes the bar code input dialog.
sap.ndc.BarcodeScanner.getStatusModel()Returns the status model of the BarcodeScanner.
sap.ndc.BarcodeScanner.scan(fnSuccess?, fnFail?, fnLiveUpdate?)Starts the bar code scanning process either showing the live input from the camera or displaying a dialog to enter the value directly if the bar code scanning feature is not available.
Method Detail
sap.ndc.BarcodeScanner.closeScanDialog()
Closes the bar code input dialog. It can be used to close the dialog before the user presses the OK or the Cancel button (e.g. in the fnLiveUpdate callback function of the sap.ndc.BarcodeScanner.scan method.)
sap.ndc.BarcodeScanner.getStatusModel(): sap.ui.model.json.JSONModel
Returns the status model of the BarcodeScanner. It is a JSON model which contains a single boolean property 'available' indicating whether or not the bar code scanner feature is available. It can be used to bind to the visible property of UI controls which have to be hidden in case the feature is unavailable.
Returns:
{sap.ui.model.json.JSONModel} A JSON model containing the 'available' property
sap.ndc.BarcodeScanner.scan(fnSuccess?, fnFail?, fnLiveUpdate?)
Starts the bar code scanning process either showing the live input from the camera or displaying a dialog to enter the value directly if the bar code scanning feature is not available.

sap.ndc.BarcodeScanner.scan(fnSuccess, fnFail, fnLiveUpdate)

The bar code scanning is done asynchronously. When it is triggered, this function returns without waiting for the scanning process to finish. The applications have to provide callback functions to react to the events of a successful scanning, an error during scanning, and the live input on the dialog.

fnSuccess is passed an object with text, format and cancelled properties. Text is the text representation of the bar code data, format is the type of the bar code detected, and cancelled is whether or not the user cancelled the scan. fnError is given the error, fnLiveUpdate is passed the new value entered in the dialog's input field. An example:

sap.ndc.BarcodeScanner.scan(
   function (mResult) {
      alert("We got a bar code\n" + 
            "Result: " + mResult.text + "\n" +
            "Format: " + mResult.format + "\n" +
            "Cancelled: " + mResult.cancelled);
   },
   function (Error) {
      alert("Scanning failed: " + Error);
   },
   function (mParams) {
      alert("Value entered: " + mParams.newValue);
   }
);
Parameters:
{function}fnSuccess? Function to be called when the scanning is done or cancelled
{function}fnFail? Function to be called when the scanning is failed
{function}fnLiveUpdate? Function to be called when value of the dialog's input is changed