neo-neo-bblessed
Version:
A fork of neo-blessed (which is a fork of blessed) with bug fixes and maintenance.
3 lines (2 loc) • 1.21 kB
JavaScript
const l=require("./node"),u=require("./box"),v=require("./button");function s(n){if(!(this instanceof l))return new s(n);n=n||{},n.hidden=!0,u.call(this,n),this._.okay=new v({screen:this.screen,parent:this,top:2,height:1,left:2,width:6,content:"Okay",align:"center",bg:"black",hoverBg:"blue",autoFocus:!1,mouse:!0}),this._.cancel=new v({screen:this.screen,parent:this,top:2,height:1,shrink:!0,left:10,width:8,content:"Cancel",align:"center",bg:"black",hoverBg:"blue",autoFocus:!1,mouse:!0})}s.prototype.__proto__=u.prototype,s.prototype.type="question",s.prototype.ask=function(n,h){const t=this;let i,r,c;this.show(),this.setContent(" "+n),this.onScreenEvent("keypress",i=function(a,e){e.name!=="mouse"&&(e.name!=="enter"&&e.name!=="escape"&&e.name!=="q"&&e.name!=="y"&&e.name!=="n"||o(null,e.name==="enter"||e.name==="y"))}),this._.okay.on("press",r=function(){o(null,!0)}),this._.cancel.on("press",c=function(){o(null,!1)}),this.screen.saveFocus(),this.focus();function o(a,e){return t.hide(),t.screen.restoreFocus(),t.removeScreenEvent("keypress",i),t._.okay.removeListener("press",r),t._.cancel.removeListener("press",c),h(a,e)}this.screen.render()},module.exports=s;
//# sourceMappingURL=question.js.map