Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B3080D10E for ; Tue, 7 Aug 2012 05:09:05 +0000 (UTC) Received: (qmail 46363 invoked by uid 500); 7 Aug 2012 05:09:05 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 46162 invoked by uid 500); 7 Aug 2012 05:09:03 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 46122 invoked by uid 99); 7 Aug 2012 05:09:02 -0000 Received: from issues-vm.apache.org (HELO issues-vm) (140.211.11.160) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Aug 2012 05:09:02 +0000 Received: from isssues-vm.apache.org (localhost [127.0.0.1]) by issues-vm (Postfix) with ESMTP id 6165E14052D for ; Tue, 7 Aug 2012 05:09:02 +0000 (UTC) Date: Tue, 7 Aug 2012 05:09:02 +0000 (UTC) From: "Hugo (JIRA)" To: callback-dev@incubator.apache.org Message-ID: <1958654504.20020.1344316142401.JavaMail.jiratomcat@issues-vm> Subject: [jira] [Created] (CB-1205) backbutton event should not fire on 'subscribe' MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 Hugo created CB-1205: ------------------------ Summary: backbutton event should not fire on 'subscribe' Key: CB-1205 URL: https://issues.apache.org/jira/browse/CB-1205 Project: Apache Cordova Issue Type: Bug Components: Android Affects Versions: 2.0.0, 1.9.0, 1.8.1 Reporter: Hugo Assignee: Joe Bowser After the backbutton has been used once, it fires every time it is subscribed to. This is a pattern that may makes sense with certain events, but it is problematic in the android world where users will expect the backbutton to do different things depending on the context (typically, when on the home screen the backbutton means "exit the app", and on any other screen it means "go back to the previous screen"). For developers to be able to implement this behavior, they need to be able to subscribe and unsubscribe the backbutton event without side-effect The pseudo js to implement a normal android behavior is something like: goPreviousScreen = function() { // Do what you need to do to return to the previous screen } // When returning to the home screen, disable the cdv handler to enable the // default behavior (exit the app & return to previous activity) document.removeEventListener("backbutton", goPreviousScreen, false) ; // When leaving the home screen document.addEventListener("backbutton", goPreviousScreen, false) ; // >> If the user exercised the backbutton once during the session // >> he can never navigate from the home screen to another screen // >> without being immediatly returned to the home screen // >> because the 'backbutton' event fires on subscription Note: this was tested & confirmed on 1.8.1, a cursory glance at the source for 1.9 and 2.0 strongly suggests that the problem affects these versions as well. -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira