Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #4063 and add select button #4064

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
16 changes: 15 additions & 1 deletion js/activity.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,9 @@ class Activity {
// Flag to indicate whether the user is performing a 2D drag operation.
this.isDragging = false;

// Flag to indicate whether user is selecting
this.isSelecting = false;

// Flag to indicate the selection mode is on
this.selectionModeOn = false;

Expand Down Expand Up @@ -5716,6 +5719,9 @@ class Activity {

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

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

if (!this.helpfulWheelItems.find(ele => ele.label === "Clean"))
this.helpfulWheelItems.push({label: "Clean", icon: "imgsrc:data:image/svg+xml;base64," + window.btoa(base64Encode(CLEARBUTTON)), display: true, fn: () => this._allClear(false)});
Expand Down Expand Up @@ -6062,6 +6068,8 @@ class Activity {
document.addEventListener(
"mousedown",
(event) => {
if (!this.isSelecting) return;
this.moving = false;
// event.preventDefault();
// event.stopPropagation();
if (event.target.id === "myCanvas") {
Expand All @@ -6082,6 +6090,11 @@ class Activity {
// end the drag on navbar
document.getElementById("toolbars").addEventListener("mouseover", () => {this.isDragging = false;});

this.selectMode = () => {
this.isSelecting = !this.isSelecting;;
if (this.moving) this.moving = false;
}

this._create2Ddrag = () => {
this.dragArea = {};
this.selectedBlocks = [];
Expand All @@ -6099,7 +6112,7 @@ class Activity {
this.hasMouseMoved = true;
// event.preventDefault();
// this.selectedBlocks = [];
if (this.isDragging){
if (this.isDragging && this.isSelecting){
this.currentX = event.clientX;
this.currentY = event.clientY;
if (!this.blocks.isBlockMoving && !this.turtles.running()) {
Expand All @@ -6114,6 +6127,7 @@ class Activity {

document.addEventListener("mouseup", (event) => {
// event.preventDefault();
if (!this.isSelecting) return;
this.isDragging = false;
this.selectionArea.style.display = "none";
this.startX = 0;
Expand Down
3 changes: 3 additions & 0 deletions js/artwork.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.