mirror of
https://github.com/google/blockly.git
synced 2026-04-28 16:10:21 +02:00
feat: Beep when attempting constrained move on top-level block (#9635)
* feat: Beep when attempting constrained move on top-level block * chore: Remove errant `only` * refactor: Add and use `playErrorBeep()`
This commit is contained in:
@@ -380,6 +380,7 @@ export class BlockDragStrategy implements IDragStrategy {
|
||||
|
||||
if (this.moveMode === MoveMode.CONSTRAINED) {
|
||||
showUnconstrainedMoveHint(this.workspace, true);
|
||||
this.workspace.getAudioManager().playErrorBeep();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,6 +138,13 @@ export class WorkspaceAudio {
|
||||
oscillator.stop(this.context.currentTime + duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Plays a standard error beep.
|
||||
*/
|
||||
async playErrorBeep() {
|
||||
return this.beep(260);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not playing sounds is currently allowed.
|
||||
*
|
||||
|
||||
@@ -534,6 +534,7 @@ suite('Keyboard-driven movement', function () {
|
||||
suite('in constrained mode', function () {
|
||||
test('prompts to use unconstrained mode when no destinations are available', function () {
|
||||
const toastSpy = sinon.spy(Blockly.Toast, 'show');
|
||||
const beepSpy = sinon.spy(this.workspace.getAudioManager(), 'beep');
|
||||
Blockly.getFocusManager().focusNode(this.element);
|
||||
const originalBounds = this.element.getBoundingRectangle();
|
||||
startMove(this.workspace);
|
||||
@@ -547,6 +548,8 @@ suite('Keyboard-driven movement', function () {
|
||||
? 'Hold ⌘ Command and use arrow keys to move freely, then Enter to accept the position'
|
||||
: 'Hold Ctrl and use arrow keys to move freely, then Enter to accept the position',
|
||||
);
|
||||
sinon.assert.calledOnce(beepSpy);
|
||||
beepSpy.restore();
|
||||
toastSpy.restore();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user