Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6857] Android: UI - the back hardware button triggers optionDialog's click event

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2018-01-03T05:52:50.000+0000
Affected Version/sRelease 1.8.0.1
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterIvan Skugor
AssigneeMaggie Chen
Created2011-10-25T06:48:23.000+0000
Updated2018-01-03T05:52:50.000+0000

Description

Problem

The Android back hardware button triggers optionDialog's click event. The click event shouldn't be triggered because of the fact dialog isn't clicked/touched with finger (back button is).

Test case

* run code below * click on the button so that optionDialog shows * hit the hardware back-button. You'll see that this triggers dialog's click event.
var win = Ti.UI.createWindow({
    modal: true,
    backgroundColor: '#000'
});
 
var button = Ti.UI.createButton({
    title: 'Open dialog'
});
 
button.addEventListener('click', function() {
 
    var dialog = Ti.UI.createOptionDialog({
        options: ['Option 1', 'Option 2', 'Option 3'],
        title: 'Options'
    });
 
    dialog.addEventListener('click', function(e) {
        Ti.API.info('Dialog click event!');
        Ti.API.debug(e);
    });
 
    dialog.show();
});
 
win.add(button);
 
win.open();

Results

Dialog click event!
{"cancel":false,"index":-268435457,"source":{"size":{"height":0,"width":0},"children":[],"height":0,"width":0,"center":{"y":0,"x":0},"options":["Option 1","Option 2","Option 3"],"title":"Options","keepScreenOn":false,"_events":{}},"button":true,"type":"click"}

Discussions

See [this Q&A question](http://developer.appcelerator.com/question/127291/android-back-button-triggers-option-dialogs-click-event).

Comments

  1. Paul Dowsett 2011-12-23

    Ivan, thank you for raising this ticket. Please note the changes I made to bring it in line with the [JIRA Ticket Checklist](https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report#HowtoSubmitaBugReport-JIRATicketChecklist). Unfortunately we cannot accept more than one issue or request in a single ticket. Would you raise an new feature request ticket for the following, if you still think it is valid? Cheers
       Also, in my opinion, "cancel" functionality of optionDialog could be redesigned, so that is supports new "cancel" event instead of "cancel" property in "click" event as implementation of functionality when no option is selected. That way, we will be able to do action when both "cancel" option is selected and hardware back-button is pressed, and on the other hand in "click" event we won't have to check if "cancel" opinion was clicked to do no action (so, "cancel" option would not produce "click" event).
       
  2. saamy 2017-05-25

    May I know why this simple issue is not fixed yet ?
  3. Maggie Chen 2017-09-26

    PR https://github.com/appcelerator/titanium_mobile/pull/9476

JSON Source