From 930d61b9f067346f467d4d84015088f57c54da56 Mon Sep 17 00:00:00 2001 From: liam4 Date: Mon, 3 Jul 2017 21:00:02 -0300 Subject: Buttons and lists - Button class name changed to Button, from ButtonInput - Button layouts are now updated with fixLayout, rather than automatically when the text property is changed - Buttons now have a height of 1, so they can generally actually be used in layouts - New example for list form elements - List form elements let you navigate with up/down (or left/right, for horizontal lists) - List forms now have nextInput and previousInput methods --- ui/form/ListScrollForm.js | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'ui/form/ListScrollForm.js') diff --git a/ui/form/ListScrollForm.js b/ui/form/ListScrollForm.js index b1484b5..b23f973 100644 --- a/ui/form/ListScrollForm.js +++ b/ui/form/ListScrollForm.js @@ -1,3 +1,5 @@ +const telc = require('../../util/telchars') + const Form = require('./Form') module.exports = class ListScrollForm extends Form { @@ -44,7 +46,27 @@ module.exports = class ListScrollForm extends Form { } keyPressed(keyBuf) { - super.keyPressed(keyBuf) + handleKeyPress: { + if (this.layoutType === 'horizontal') { + if (telc.isLeft(keyBuf)) { + this.previousInput() + break handleKeyPress + } else if (telc.isRight(keyBuf)) { + this.nextInput() + break handleKeyPress + } + } else if (this.layoutType === 'vertical') { + if (telc.isUp(keyBuf)) { + this.previousInput() + break handleKeyPress + } else if (telc.isDown(keyBuf)) { + this.nextInput() + break handleKeyPress + } + } + + super.keyPressed(keyBuf) + } const sel = this.inputs[this.curIndex] -- cgit 1.3.0-6-gf8a5