Я сделал следующее, чтобы установить и использовать сканер штрих-кода.
>phonegap plugin add https://github.com/jonathannaguin/BarcodeScanner
это успешно установило плагин сканера штрих-кода в каталог phonegap/plugins.
Затем я построил его для Android, как это
phonegap build android
Это также закончилось успешно. Затем я поместил это в сенсорное приложение сенча, используя обработчик в текстовом поле. Но при постукивании по полю результата нет. Ничего не произошло.
Ext.define("Tasks.view.BarcodeField", {
extend: 'Ext.Container',
alias:'widget.barcodeField',
xtype: 'barcodefield',
config: {
layout: 'hbox',
id: 'barcodeField',
itemId: 'barcodeField',
items: [
{
xtype: 'textfield',
label: 'Barcode',
labelWidth: '37.4%',
flex: 4
},
{
xtype: 'image',
id : 'barcodeScanner',
itemId : 'barcodeScanner',
src: 'resources/images/barcodes.png',
padding: '6 0 0 0',
flex: 1,
listeners: {
tap: function() {
console.log("Starting the barcode Scanner");
function success(result) {
alert("We got a barcode\n" +
"Result: " + result.text + "\n" +
"Format: " + result.format + "\n" +
"Cancelled: " + result.cancelled);
}
function fail(error) {
alert("Scanning failed: " + error);
}
cordova.plugins.barcodeScanner.scan(success, fail);
}
}
}
]
},
getValue : function()
{
console.log(this.getItems().getAt(0).getValue());
return this.getItems().getAt(0).getValue();
},
setValue : function(newvalue) {
this.getItems().getAt(0).setValue(newvalue);
}
});
Я вижу, что вызывается обработчик касания и оператор журнала на консоли.