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/Button.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'ui/form/Button.js') diff --git a/ui/form/Button.js b/ui/form/Button.js index 86347a0..cf7262f 100644 --- a/ui/form/Button.js +++ b/ui/form/Button.js @@ -3,7 +3,7 @@ const telc = require('../../util/telchars') const FocusElement = require('./FocusElement') -module.exports = class ButtonInput extends FocusElement { +module.exports = class Button extends FocusElement { // A button. constructor(text) { @@ -15,17 +15,9 @@ module.exports = class ButtonInput extends FocusElement { this.cursorY = null } - // Setting the text of the button should change the width of the button to - // fit the text. - // - // TODO: Make this happen in fixLayout - set text(newText) { - this._text = newText - this.w = newText.length - } - - get text() { - return this._text + fixLayout() { + this.w = this.text.length + this.h = 1 } drawTo(writable) { -- cgit 1.3.0-6-gf8a5