Skip to content

Commit c8ac9c6

Browse files
add select to right-hand menu
1 parent 75f615a commit c8ac9c6

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

js/activity.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ class Activity {
495495
(event) => {
496496
event.preventDefault();
497497
event.stopPropagation();
498-
if (!this.beginnerMode && !this.isSelecting) {
498+
if (!this.beginnerMode) {
499499
if (event.target.id === "myCanvas") {
500500
this._displayHelpfulWheel(event);
501501
}
@@ -5719,6 +5719,9 @@ class Activity {
57195719

57205720
if (!this.helpfulWheelItems.find(ele => ele.label === "Grid"))
57215721
this.helpfulWheelItems.push({label: "Grid", icon: "imgsrc:data:image/svg+xml;base64," + window.btoa(base64Encode(CARTESIANBUTTON)), display: true, fn: piemenuGrid});
5722+
5723+
if (!this.helpfulWheelItems.find(ele => ele.label === "Select"))
5724+
this.helpfulWheelItems.push({label: "Select", icon: "imgsrc:data:image/svg+xml;base64," + window.btoa(base64Encode(SELECTBUTTON)), display: true, fn: this.selectMode });
57225725

57235726
if (!this.helpfulWheelItems.find(ele => ele.label === "Clean"))
57245727
this.helpfulWheelItems.push({label: "Clean", icon: "imgsrc:data:image/svg+xml;base64," + window.btoa(base64Encode(CLEARBUTTON)), display: true, fn: () => this._allClear(false)});
@@ -6065,7 +6068,7 @@ class Activity {
60656068
document.addEventListener(
60666069
"mousedown",
60676070
(event) => {
6068-
if (event.button !==2) return;
6071+
if (!this.isSelecting) return;
60696072
this.moving = false;
60706073
// event.preventDefault();
60716074
// event.stopPropagation();
@@ -6087,6 +6090,11 @@ class Activity {
60876090
// end the drag on navbar
60886091
document.getElementById("toolbars").addEventListener("mouseover", () => {this.isDragging = false;});
60896092

6093+
this.selectMode = () => {
6094+
this.isSelecting = !this.isSelecting;;
6095+
if (this.moving) this.moving = false;
6096+
}
6097+
60906098
this._create2Ddrag = () => {
60916099
this.dragArea = {};
60926100
this.selectedBlocks = [];
@@ -6119,8 +6127,7 @@ class Activity {
61196127

61206128
document.addEventListener("mouseup", (event) => {
61216129
// event.preventDefault();
6122-
if (event.button !== 2) return;
6123-
this.moving = true;
6130+
if (!this.isSelecting) return;
61246131
this.isDragging = false;
61256132
this.selectionArea.style.display = "none";
61266133
this.startX = 0;

js/turtles.js

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,6 @@ Turtles.TurtlesView = class {
577577
this._collapseButton = null; // used by add method
578578
this._clearButton = null; // used by add method
579579
this.gridButton = null; // used by add method
580-
this.selectButton = null; // used to enable select mode
581580
this.collapse = null;
582581
this.expand = null;
583582

@@ -872,26 +871,6 @@ Turtles.TurtlesView = class {
872871
this.activity.refreshCanvas();
873872
};
874873

875-
/**
876-
* Makes 'select' button by initailising 'SELECTBUTTON' SVG.
877-
* Toggles isSelecting on click.
878-
*/
879-
const __makeSelectButton = () => {
880-
this.selectButton = _makeButton(
881-
SELECTBUTTON,
882-
{
883-
"name":"Select",
884-
"label":_("Select")
885-
},
886-
this._w - 10 - 4 * 55,
887-
70 + LEADING + 6
888-
);
889-
const that = this;
890-
this.selectButton.onclick = () => {
891-
this.activity.isSelecting = !this.activity.isSelecting;
892-
};
893-
};
894-
895874
/**
896875
* Makes 'cartesian' button by initailising 'CARTESIANBUTTON' SVG.
897876
* Assigns click listener function to doGrid() method.
@@ -1191,7 +1170,6 @@ Turtles.TurtlesView = class {
11911170
__makeExpandButton();
11921171
__makeClearButton();
11931172
__makeGridButton();
1194-
__makeSelectButton();
11951173
jQuery.noConflict()(".tooltipped").each(function(){
11961174
jQuery.noConflict()(this).tooltip(
11971175
{

0 commit comments

Comments
 (0)