Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16975] BlackBerry: AlertDialog button clicks always returning the same index and cancel value

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-05-22T17:26:46.000+0000
Affected Version/sRelease 3.3.0
Fix Version/sRelease 3.3.0, Release 3.4.0
ComponentsBlackBerry
Labelsn/a
ReporterChris Barber
AssigneePedro Enrique
Created2014-05-16T20:55:20.000+0000
Updated2014-06-10T20:41:10.000+0000

Description

From an AlertDialog, button clicks emit the same source and index in the event object. The index should be different for each button.
Ti.UI.setBackgroundColor('white');
var win = Ti.UI.createWindow({
  title: 'Click window to test',
  backgroundColor: 'white',
  exitOnClose: true,
  fullscreen: false
});
win.addEventListener('click', function(e){
  var dialog = Ti.UI.createAlertDialog({
    cancel: 1,
    buttonNames: ['Confirm', 'Cancel', 'Help'],
    message: 'Would you like to delete the file?',
    title: 'Delete'
  });
  dialog.addEventListener('click', function(e){
    if (e.index === e.source.cancel){
      Ti.API.info('The cancel button was clicked');
    }
    Ti.API.info('e.cancel: ' + e.cancel);
    Ti.API.info('e.source.cancel: ' + e.source.cancel);
    Ti.API.info('e.index: ' + e.index);
  });
  dialog.show();
});
win.open();

Comments

  1. Pedro Enrique 2014-05-22

    PR for Master: https://github.com/appcelerator/titanium_mobile_blackberry/pull/237 PR for 3.3.X https://github.com/appcelerator/titanium_mobile_blackberry/pull/238
  2. Olga Romero 2014-06-10

    Tested and verified fixed with: Mac osx 10.9.3 Mavericks Appcelerator Studio, build: 3.3.0.201406061445 Titanium SDK, build: 3.3.0.v20140609184912 Node.JS Version: v0.10.13 NPM Version: 1.3.2 acs@1.0.14 alloy@1.4.0-beta npm@1.3.2 titanium@3.3.0-beta2 titanium-code-processor@1.1.1 Device: BB Z10 (10.2.1)

    Actual result

    different index clicking different buttons(e.g. Confirm Cancel Help)
       [INFO] The cancel button was clicked
       [INFO] e.cancel: 1
       [INFO] e.source.cancel: 1
       [INFO] e.index: 1
       [INFO] e.cancel: 0
       [INFO] e.source.cancel: 1
       [INFO] e.index: 0
       [INFO] The cancel button was clicked
       [INFO] e.cancel: 1
       [INFO] e.source.cancel: 1
       [INFO] e.index: 1
       [INFO] e.cancel: 0
       [INFO] e.source.cancel: 1
       [INFO] e.index: 2
       

JSON Source