Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    24
    Vote Rating
    0
    treike is on a distinguished road

      0  

    Default Blackberry Back Button in Phonegap no longer working when Sencha added

    Blackberry Back Button in Phonegap no longer working when Sencha added


    I've created a Sencha Touch App and I am using this with Phonegap to generate a Blackberry App.

    I want to make use of the hardware back button, which is possible via BB Webworks and works, but only as long as I don't add Sencha Touch. It works fine when not using Sencha Touch, but the event seems not to be caught when Sencha Touch js-files are added.



    Code:
           <script type="text/javascript">    
             blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, 
                function() { 
                    alert("back");
                    //history.back();
                    return true;
                }); 
        </script>
    Any clues why?

    Thanks!

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,547
    Vote Rating
    872
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I wouldn't see any reason how we would prohibit a physical button.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    24
    Vote Rating
    0
    treike is on a distinguished road

      0  

    Default


    I can't see any reason too, but it's just like that.

    I've tested:

    A clean app, no code of myself included (except the event listener js).

    I just added only sencha-touch.js and then the eventlistener shows the defined "back"-alert.

    Then I added the ST "HelloWorld" example js and as soon as "Hello World" is shown on the canvas the evenlistener is no longer catching the event, the app closes. Before Hello World is shown, the event listener still shows the alert.

    I think that as soon as Ext.Application or Ext.regApplication is called, the BB back button is no longer working as expected.

  4. #4
    Sencha User
    Join Date
    Aug 2011
    Posts
    24
    Vote Rating
    0
    treike is on a distinguished road

      0  

    Default


    Would it help if I send a zip of my test code somewhere?

  5. #5
    Sencha User
    Join Date
    Aug 2011
    Posts
    24
    Vote Rating
    0
    treike is on a distinguished road

      0  

    Default


    So, to bump this one up.

    I think it is very obvious that Sencha Touch is doing something that prevents the BB BackButton event.

    This is working, I always catch the event and can display the alert.
    HTML Code:
    <!DOCTYPE html>
    <html>
    <head>
        <title>Back Test</title>
        <script src="lib/sencha-touch-debug-w-comments.js" type="text/javascript" charset="utf-8"></script>
        
        <script type="text/javascript"> 
    
    
         /* new Ext.Application({
                launch: function() {
                    new Ext.Panel({
                        fullscreen: true,
                        html: 'Hello World!'
                    });
                }
            });*/
    
    
        </script>
        
        <script>
        function trapBackKey(){
            alert("trapped");
            blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, 
                function() { 
                    //window.history.back();
                    alert("menu");
                    return false;
                }); 
        }
        
        trapBackKey();
        </script>
    </head>
    <body>
    </body>
    </html>
    Commenting the "new Ext.Application" back in, it's no longer working. For a short amount of time I can catch the event, until shortly before "Hello World" is displayed. When I click the back button after the display of "Hello World" the app closes instead of showing the alert.

    HTML Code:
    <!DOCTYPE html>
    <html>
    <head>
        <title>Back Test</title>
        
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=1.0;" />
        
        <script src="lib/sencha-touch-debug-w-comments.js" type="text/javascript" charset="utf-8"></script>
        
        <script type="text/javascript"> 
    
    
            new Ext.Application({
                launch: function() {
                    new Ext.Panel({
                        fullscreen: true,
                        html: 'Hello World!'
                    });
                }
            });
    
    
        </script>
        
        <script>
        function trapBackKey(){
            alert("trapped");
            blackberry.system.event.onHardwareKey(blackberry.system.event.KEY_BACK, 
                function() { 
                    //window.history.back();
                    alert("menu");
                    return false;
                }); 
        }
        
        trapBackKey();
        </script>
    </head>
    <body>
    </body>
    </html>
    So there has to be something when loading the Ext-App that prevents the blackberry event, isn't it?

    Maybe someone could just give me a hint or something else?

  6. #6
    Sencha User
    Join Date
    Aug 2011
    Posts
    24
    Vote Rating
    0
    treike is on a distinguished road

      0  

    Default


    So for anyone being lucky do develop for Blackberrys :
    While I did get it to work without futher ado with a jQuery mobile app, I couldn't get it to work for Sencha Touch the way described in den Blackberry documents and above.

    But I found a workaround for this one.

    I found out that the BB BackButton is mapped in Javascript to a KeyCode of 27 (escape). So I defined a keydown listener and handled that event appropriately. But you have to prevent further propagation of the event. Otherwise the app still exits instead of going back.

    Hope this helps someone else, too.

  7. #7
    Sencha User
    Join Date
    Aug 2007
    Posts
    11
    Vote Rating
    1
    composer47 is on a distinguished road

      0  

    Default Turn off animations

    Turn off animations


    I'm not sure why, but whenever Sencha animates a Sheet or View, the back button breaks. The solution is to turn off animations for Blackberry.

    You can see how to do that (and other Blackberry tips) here:

    http://www.sencha.com/forum/showthre...%28Webworks%29