Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-18500] Android: event.cancel not set properly for optionsDialog

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2017-11-13T23:55:32.000+0000
Affected Version/sRelease 3.3.0, Release 3.4.1, Release 3.5.0
Fix Version/sRelease 7.0.0
ComponentsAndroid
LabelsTCSupport
ReporterNeville Dastur
AssigneeMaggie Chen
Created2014-09-05T11:16:43.000+0000
Updated2017-11-17T01:32:45.000+0000

Description

Problem Description

When using optionDialog on android the click event returns depending on buttons vs options being clicked. even.cancel is true when the cancel button is clicked, however it also gets set to true when the option with same index is clicked or an additional test for event.button needs to be performed. Really this should happen at the SDK level.

Steps to reproduce

1. Create a new mobile project (Ti Classic) 2. Add this to app.js:
 
var win = Ti.UI.createWindow({
  backgroundColor: 'white',
  exitOnClose: true,
});

var opts = {
  title: 'Delete File?'
};

var isAndroid = Ti.Platform.osname == 'android';

if(isAndroid){
  opts.options = ['Confirm', 'Cancel'];
  opts.buttonNames = ['Help'];
  //opts.Help = 0;
} else {
  opts.options = ['Confirm', 'Help', 'Cancel'];
}

var dialog;
win.addEventListener('click',function(){
    dialog = Ti.UI.createOptionDialog(opts);
    dialog.show();
    dialog.addEventListener('click', onSelectDialog);
});

function onSelectDialog(event){
	if(isAndroid){
            //  event.button===true test is necessary 
            if(event.button === true /*&& event.Help === true*/) alert("ok");
        }
   //alert("ok") ;
}

win.open();
3. Run it in device.

Comments

  1. Maggie Chen 2017-09-25

    PR https://github.com/appcelerator/titanium_mobile/pull/9476
  2. Lokesh Choudhary 2017-11-10

    FR Passed. Waiting for merge to get enabled.
  3. Lokesh Choudhary 2017-11-13

    PR Merged.
  4. Abir Mukherjee 2017-11-15

    Changes are seen in SDK 7.0.0.v20171114203226. Need to wait for CR to be completed before closing.
  5. Lokesh Choudhary 2017-11-17

    Verified the fix in SDK 7.0.0.v20171116132144. Closing. Studio Ver: 5.0.0.201711161920 SDK Ver: 7.0.0.v20171116132144 OS Ver: 10.12.3 Xcode Ver: Xcode 8.3.3 Appc NPM: 4.2.11-2 Appc CLI: 7.0.0-master.27 Ti CLI Ver: 5.0.14 Alloy Ver: 1.10.9 Node Ver: 8.9.1 Java Ver: 1.8.0_101 Devices: ⇨ google Pixel --- Android 7.1.1 ⇨ google Nexus 5 --- Android 6.0.1

JSON Source