From c3edce729d6580191563619f71a9e0b216f257cd Mon Sep 17 00:00:00 2001 From: sbosse Date: Tue, 27 Aug 2024 00:15:59 +0200 Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024 --- test/test-ui2.js | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 test/test-ui2.js diff --git a/test/test-ui2.js b/test/test-ui2.js new file mode 100644 index 0000000..b24fd3b --- /dev/null +++ b/test/test-ui2.js @@ -0,0 +1,45 @@ +// jamsh +var ui = UI.UI({ + pages : 1, + styles : {}, + terminal: '', + title : 'Test APP' +}); + +function exit2() { + process.exit(); +} + +print(ui) +ui.init(); + + +ui.pages[1]={ + quit : ui.button({left:1,top:1,content:'QUIT', action:exit2}), + label1 : ui.label({right:1,top:2, content:'Select Button Demo'}), + check1 : ui.checkbox({left:1,top:6,text:'Select 1',value:false}), + check2 : ui.checkbox({left:1,top:8,text:'Select 2',value:true}), + check3 : ui.checkbox({left:1,top:10,text:'Select 3',value:false}), + radio1 : ui.radiobutton({left:1,top:12,text:'Choice 1', group:1, value:false}), + radio2 : ui.radiobutton({left:1,top:14,text:'Choice 2', group:1 ,value:true}), + radio3 : ui.radiobutton({left:1,top:16,text:'Choice 3', group:1,value:false}), + info1 : ui.info({right:1, top:6, width:40, height:14, multiline:true, wrap:true, scrollable:true, label:'Info'}), +} +_logs=[] +Log = function () { + var line = Array.prototype.slice.call(arguments).map(function (arg) { + return inspect(arg) }).join(' '); + _logs.push(_logs.length+':'+line); + ui.pages[1].info1.setValue(_logs.join('\n')); + ui.pages[1].info1.scrollBottom(); +} + +ui.screen.key(['escape', 'q', 'C-c'], exit2); +ui.pages[1].check1.on('select',Log); +ui.pages[1].check2.on('select',Log); +ui.pages[1].check3.on('select',Log); +ui.pages[1].radio1.on('select',Log); +ui.pages[1].radio2.on('check',Log); +ui.pages[1].radio3.on('check',Log); + +ui.start();