sencha-touch using ActionSheet

拥有回忆 提交于 2019-12-08 10:49:02

问题


I am trying to use an ActionSheet to present the user several options to continue. I want to add a simple text box in the middle of the screen to describe the problem to the user.
Is there a simple/standard way to put such a prompt in Sencha-Touch?


回答1:


You'll need to do something like this on your overlay ...

if (!this.popup) {
  this.popup = new Ext.Panel({
    hideOnMaskTap: false,
    floating: true,
    modal: true,
    centered: true,
    hideOnMaskTap: false,
    width: 300,
    height: 200,
    styleHtmlContent: true,
    scroll: 'vertical',
    html: '<p>msg here</p>'
  });
}
this.popup.show('pop');

The key here being hideOnMaskTap: false, this will prevent the overlay from disappearing when you click in it's masked area.

You can then display your action sheet but you must remember to hide the overlay in the handler(s) for your action sheet buttons since it will no longer go away when you tap in the masked area.

if (!this.actions) {
  this.actions = new Ext.ActionSheet({
    items: [{
      text: 'decline',
      ui: 'decline',
      handler: function() {
        this.doWhateverYouNeedToDo();
        this.actions.hide();
        this.popup.hide();
      }
    }, {
      text: 'save',
      handler: function() {
        this.doWhateverYouNeedToDo();
        this.actions.hide();
        this.popup.hide();
      }
    }, {
      text: 'cancel',
      scope: this,
      handler: function() {
        this.doWhateverYouNeedToDo();
        this.actions.hide();
        this.popup.hide();
      }
    }]
  });
}
this.actions.show();

note the hiding of the overlay in the sheet handlers.. (i don't do it above but you'll more than likely want to destroy the overlay and the action sheet after they are hidden as well just to keep things tidey)




回答2:


You can use an Overlay popup to display a message after the ActionSheet renders.



来源:https://stackoverflow.com/questions/7138899/sencha-touch-using-actionsheet

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!