From 99a4890aa07d14e58aa8cbb0016383cfedb45a3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jens=20M=C3=B6nig?= Date: Wed, 24 Jul 2024 15:29:06 +0200 Subject: [PATCH] reverted piano keyboard behavior --- HISTORY.md | 1 + src/widgets.js | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 44f8462af..ecbf256e2 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -128,6 +128,7 @@ * widgets: added ability to switch octaves in the piano keyboard widget, thanks, ego-lay-atman-bay! * gui: added credits for ego-lay-atman-bay * v10-rc6 +* reverted piano keyboard behavior ### 2024-07-22 * edited help screen for doDeleteBlock, converted to PNG, reduced file size diff --git a/src/widgets.js b/src/widgets.js index 7a4b9bdf4..beec3e98d 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -3692,15 +3692,15 @@ PianoMenuMorph.prototype.processKeyDown = function (event) { case 40: // 'down arrow' case 189: // - return event.shiftKey ? - this.octaveUp() - : this.octaveDown(); + this.octaveDown() + : this.selectDown(); case 38: // 'up arrow' case 39: // 'right arrow' case 187: // + case 220: // # return event.shiftKey ? - this.octaveDown() - : this.octaveUp(); + this.octaveUp() + : this.selectUp(); default: switch(event.key) { case 'c': @@ -3739,6 +3739,22 @@ PianoMenuMorph.prototype.processKeyDown = function (event) { } }; +PianoMenuMorph.prototype.selectUp = function () { + this.selectKey( + this.selection ? + Math.min(this.selection.action + 1, 143) + : 1 + ); +}; + +PianoMenuMorph.prototype.selectDown = function () { + this.selectKey( + this.selection ? + Math.max(this.selection.action - 1, 0) + : 1 + ); +}; + PianoMenuMorph.prototype.octaveUp = function () { this.octave += this.visibleOctaves; this.octave = Math.min(this.octave, 10 - (11) % this.visibleOctaves);