Skip to content

Commit

Permalink
add undo/redo shortcut and idea selection-indicator to LabyrinthJS
Browse files Browse the repository at this point in the history
While linking ideas, no selection-indicator of selected idea was visible thereby creating confusion.
Added a selection-indicator to the currently selected idea and auto-deselect after making a link.

Signed-off-by: Aayush Raj <[email protected]>
  • Loading branch information
44yu5h committed Apr 5, 2024
1 parent bb07df3 commit f4dbd76
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion activities/LabyrinthJS.activity/js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,18 @@ define(["sugar-web/activity/activity", "l10n", "sugar-web/datastore", "sugar-web
if (lastSelected == this) lastSelected = null;
return;
} else if (currentMode == 1) {
if (isSelectedNode(this)) {
unselectNode(this);
lastSelected = null;
}
else { selectNode(this); }
if (lastSelected != null && lastSelected != this) {
createEdge(lastSelected, this);
unselectNode(this);
lastSelected = null;
pushState();
}
lastSelected = this;
if (isSelectedNode(this)) lastSelected = this;
return;
} else {
if (isSelectedNode(this)) {
Expand Down Expand Up @@ -639,6 +646,14 @@ define(["sugar-web/activity/activity", "l10n", "sugar-web/datastore", "sugar-web
undoButton.addEventListener('click', function () { undoState(); }, true);
var redoButton = document.getElementById("redo-button");
redoButton.addEventListener('click', function () { redoState(); }, true);
document.addEventListener('keydown', function (event) {
if (event.ctrlKey && event.key === 'z' || event.key === 'Z') {
undoState();
}
if (event.ctrlKey && (event.key === 'y' || event.key === 'Y')) {
redoState();
}
});

var reinitState = function() {
stateHistory = [];
Expand Down

0 comments on commit f4dbd76

Please sign in to comment.