我正在使用blessed开发一个终端应用程序,其中表单包含列表,文本框,按钮。我无法使用箭头键完全浏览列表项。
var blessed = require('blessed');
// Create a screen object.
var screen = blessed.screen({
smartCSR: true
});
screen.title = 'my window title';
var parentform = blessed.form({
parent: screen,
keys: true,
left: 0,
top: 2,
width: 80,
height: 50,
// bg: 'green',
content: '',
border:{
type:'line'
},
style:{
border:{
fg:'green',
bg:'green'
}
}
});
var list = blessed.List({
top:2,
left:'center',
parent:parentform,
height:8,
width:20,
mouse:true,
keys:true,
items:["abc","xyz","123","456"],
border:{
type:'line'
},
style:{
selected:{
bg:'blue',
fg:'white'
},
item:{
bg:'white',
fg:'blue'
},
// focus:{
// bg:'red'
// }
}
});
var parentform_cb1 = blessed.Checkbox({
parent: parentform,
top:12,
left:10,
content:"cb1",
height:1,
width:12,
// bg:'white',
mouse:true
});
var parentform_cb2 = blessed.Checkbox({
parent: parentform,
top:14,
left:10,
content:"cb2",
height:1,
width:12,
// bg:'white',
mouse:true
});
var parentform_cb3 = blessed.Checkbox({
parent: parentform,
top:16,
left:10,
content:"cb3",
height:1,
width:12,
// bg:'white',
mouse:true
});
var parentform_cb4 = blessed.Checkbox({
parent: parentform,
top:18,
left:10,
content:"cb4",
height:1,
width:12,
// bg:'white',
mouse:true
});
var parentform_cb5 = blessed.Checkbox({
parent: parentform,
top:20,
left:10,
content:"cb5",
height:1,
width:12,
// bg:'white',
mouse:true
});
screen.key(['escape', 'q', 'C-c'], function(ch, key) {
return process.exit(0);
});
list.focus();
screen.render();
我希望使用向上和向下箭头键将列表项遍历到末尾(顶部或底部),然后移至下一个小部件。
但是我得到的结果是,如果选择了列表中的下一个项目,并且一旦按下了向下箭头,则焦点将变为下一个小部件。