Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 8 additions & 5 deletions js/piemenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -3582,12 +3582,15 @@ const piemenuGrid = (activity) => {
activity.turtles.gridWheel.clockwise = false;
activity.turtles.gridWheel.initWheel(grids);
activity.turtles.gridWheel.createWheel();
activity.turtles.gridWheel.navigateWheel(
activity.turtles.currentGrid ? activity.turtles.currentGrid : 0
);

const storedGrid = activity.turtles.currentGrid ?? 0;
activity.turtles.gridWheel.navigateWheel(storedGrid);

for (let i = 0; i < gridLabels.length; i++) {
activity.turtles.gridWheel.navItems[i].navigateFunction = activity.turtles.doGrid;
activity.turtles.gridWheel.navItems[i].navigateFunction = function () {
activity.hideGrids();
activity.turtles.currentGrid = i;
activity.turtles.doGrid(i);
};
activity.turtles.gridWheel.navItems[i].setTooltip(gridLabels[i]);
}

Expand Down
13 changes: 13 additions & 0 deletions js/turtles.js
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,10 @@ Turtles.TurtlesView = class {
menuIcon.innerHTML = "menu";
docById("toggleAuxBtn").className -= "blue darken-1";
}
// Store the currently selected grid
if (this.activity.turtles.currentGrid !== undefined) {
this.selectedGrid = this.activity.turtles.currentGrid;
}
this._expandButton.style.visibility = "visible";
this._collapseButton.style.visibility = "hidden";
this.gridButton.style.visibility = "hidden";
Expand Down Expand Up @@ -1049,6 +1053,15 @@ Turtles.TurtlesView = class {
this.gridButton.visible = true;
}

// Restore the previously selected grid
if (this.selectedGrid !== undefined) {
this.activity.turtles.currentGrid = this.selectedGrid;
this.activity.turtles.doGrid(this.selectedGrid);
} else {
this.activity.turtles.currentGrid = 0;
this.activity.turtles.doGrid(0);
}

// remove the stage and add it back in position 0
this.masterStage.removeChild(turtlesStage);
this.masterStage.addChildAt(turtlesStage, 0);
Expand Down