mirror of
https://github.com/google/blockly.git
synced 2026-01-04 15:40:08 +01:00
feat: Beep when navigating across nesting levels (#9521)
This commit is contained in:
@@ -1990,6 +1990,22 @@ export class BlockSvg
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns how deeply nested this block is in parent C-shaped blocks.
|
||||||
|
*
|
||||||
|
* @internal
|
||||||
|
* @returns The nesting level of this block, starting at 0 for root blocks.
|
||||||
|
*/
|
||||||
|
getNestingLevel(): number {
|
||||||
|
// Don't consider value blocks to be nested.
|
||||||
|
if (this.outputConnection) {
|
||||||
|
return this.getParent()?.getNestingLevel() ?? 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const surroundParent = this.getSurroundParent();
|
||||||
|
return surroundParent ? surroundParent.getNestingLevel() + 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Announces the current dynamic state of the specified block, if any.
|
* Announces the current dynamic state of the specified block, if any.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -542,6 +542,17 @@ export class LineCursor extends Marker {
|
|||||||
* @param newNode The new location of the cursor.
|
* @param newNode The new location of the cursor.
|
||||||
*/
|
*/
|
||||||
setCurNode(newNode: IFocusableNode) {
|
setCurNode(newNode: IFocusableNode) {
|
||||||
|
const oldBlock = this.getSourceBlock();
|
||||||
|
const newBlock = this.getSourceBlockFromNode(newNode);
|
||||||
|
if (
|
||||||
|
oldBlock &&
|
||||||
|
newBlock &&
|
||||||
|
oldBlock.getNestingLevel() !== newBlock.getNestingLevel()
|
||||||
|
) {
|
||||||
|
newBlock.workspace
|
||||||
|
.getAudioManager()
|
||||||
|
.beep(400 + newBlock.getNestingLevel() * 40);
|
||||||
|
}
|
||||||
getFocusManager().focusNode(newNode);
|
getFocusManager().focusNode(newNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user