From 571026560ec61e26c4498f3d7e9a982c9b5aa68e Mon Sep 17 00:00:00 2001 From: Florrie Date: Fri, 20 Sep 2019 17:06:03 -0300 Subject: Jump to menubar options with keyboard I _love_ the KeyboardSelector tool. --- ui.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'ui.js') diff --git a/ui.js b/ui.js index de3ab98..d70bc31 100644 --- a/ui.js +++ b/ui.js @@ -3355,6 +3355,8 @@ class Menubar extends ListScrollForm { this.contextMenu = null this.color = 4 // blue this.attribute = 2 // dim + + this.keyboardSelector = new KeyboardSelector(this) } select() { @@ -3370,6 +3372,7 @@ class Menubar extends ListScrollForm { } this.root.select(this) + this.keyboardSelector.reset() } keyPressed(keyBuf) { @@ -3380,12 +3383,13 @@ class Menubar extends ListScrollForm { return false } - // For fun :) - if (telc.isCaselessLetter(keyBuf, 'c')) { + if (this.keyboardSelector.keyPressed(keyBuf)) { + return false + } else if (telc.isCaselessLetter(keyBuf, 'c')) { + // For fun :) this.color = (this.color % 8) + 1 return false - } - if (telc.isCaselessLetter(keyBuf, 'a')) { + } else if (telc.isCaselessLetter(keyBuf, 'a')) { this.attribute = (this.attribute % 3) + 1 return false } @@ -3408,6 +3412,7 @@ class Menubar extends ListScrollForm { container.w = button.w + 2 container.h = 1 container.selected = () => this.root.select(button) + container.keyboardIdentifier = text button.on('pressed', () => { this.contextMenu = this.showContextMenu({ -- cgit 1.3.0-6-gf8a5