2012-12-22 32 views
1

有没有什么办法将android中的默认后退按钮事件映射到sencha touch而不使用phonegap/cordova?安卓后退按钮事件与Sencha的映射

+0

你到底要后退按钮做什么?如果你想在视图之间移动,那么你应该使用哈希路由。即使应用程序没有本地捆绑,这些也可以工作。 – OhmzTech

+0

我有哈希路由...是的,但工作,但我希望后退按钮基本上回去像window.history.back()像在任何浏览器的屏幕。相反,现在它只是退出应用程序,这是不是我想要的...我问的是,有没有办法将window.history.back()映射到android的后退按钮使用sencha ??? –

回答

1

可能是这样的,有益的:

if (Ext.os.is('Android')) { 
     document.addEventListener("backbutton", Ext.bind(onBackKeyDown, this), false); // add back button listener 
     function onBackKeyDown(e) { 
      e.preventDefault(); 
      // You are at the home screen 
      if (Ext.Viewport.getActiveItem().xtype == selectedHomePage.xtype){ 
       Ext.Msg.confirm(
        "", 
        Are You sure, exit?, 
        function(buttonId) { 
         if(buttonId === 'yes') { 
          navigator.app.exitApp(); 
         } 
       }, this); 
      } else { 
      } 
     } 
    }