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. --- todo.txt | 6 ++++++ ui.js | 13 +++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/todo.txt b/todo.txt index 9e03156..fc57067 100644 --- a/todo.txt +++ b/todo.txt @@ -407,3 +407,9 @@ TODO: Investigate why reveal() has distinct support for grouplikes as well as TODO: Make the menubar work like context menus for keyboard selection, e.g. pressing P should select 'Playback' (not bubble to the app element and rewind to the previous track). + (Done!) + +TODO: Implement a UI in the playback info pane that shows when multiple players + exist at once. Make sure it's mouse-interactive, too! + +TODO: Add a menu for controlling the multiple-players code through the menubar. 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