Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/line_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,22 @@ export class LineCursor extends Marker {
this.updateFocusIndication(oldNode, newNode);
}

override hide(): void {
super.hide();

// If there's a block currently selected, remove the selection since the
// cursor should now be hidden.
const curNode = this.getCurNode();
if (curNode.getType() === ASTNode.types.BLOCK) {
const block = curNode.getLocation() as Blockly.BlockSvg;
if (!block.isShadow()) {
Blockly.common.setSelected(null);
} else {
block.removeSelect();
}
}
}

/**
* Implements fake selection of shadow blocks as described in
* documentation for setCurNode.
Expand Down
6 changes: 3 additions & 3 deletions src/navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ export class Navigation {
* - Resume editing by returning the cursor to its previous location, if any.
* - Move the cursor to the top connection point on on the first top block.
* - Move the cursor to the default location on the workspace.
*
*
* @param workspace The main Blockly workspace.
* @param keepPosition Whether to retain the cursor's previous position.
*/
Expand Down Expand Up @@ -1139,7 +1139,7 @@ export class Navigation {
// Although it seems like this should never happen, the typings are wrong
// in the base Marker class and this can therefore be null.
if (this.markedNode) {
this.passiveFocusIndicator.show(this.markedNode);
// this.passiveFocusIndicator.show(this.markedNode);
}
}

Expand All @@ -1149,7 +1149,7 @@ export class Navigation {
* @param workspace The workspace.
*/
removeMark(workspace: Blockly.WorkspaceSvg) {
this.passiveFocusIndicator.hide();
// this.passiveFocusIndicator.hide();
this.markedNode = null;
}

Expand Down
5 changes: 5 additions & 0 deletions src/navigation_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ export class NavigationController {
this.hasNavigationFocus = isFocused;
if (isFocused) {
this.navigation.focusWorkspace(workspace, true);
} else {
// Hide cursor to indicate lost focus. Also, mark the current node so that
// it can be properly restored upon returning to the workspace.
this.navigation.markAtCursor(workspace);
workspace.getCursor()?.hide();
}
}

Expand Down