@@ -260,6 +260,9 @@ class Activity {
260260 // Flag to indicate whether the user is performing a 2D drag operation.
261261 this . isDragging = false ;
262262
263+ // Flag to indicate whether user is selecting
264+ this . isSelecting = false ;
265+
263266 // Flag to indicate the selection mode is on
264267 this . selectionModeOn = false ;
265268
@@ -5716,6 +5719,9 @@ class Activity {
57165719
57175720 if ( ! this . helpfulWheelItems . find ( ele => ele . label === "Grid" ) )
57185721 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 } ) ;
57195725
57205726 if ( ! this . helpfulWheelItems . find ( ele => ele . label === "Clean" ) )
57215727 this . helpfulWheelItems . push ( { label : "Clean" , icon : "imgsrc:data:image/svg+xml;base64," + window . btoa ( base64Encode ( CLEARBUTTON ) ) , display : true , fn : ( ) => this . _allClear ( false ) } ) ;
@@ -6062,6 +6068,8 @@ class Activity {
60626068 document . addEventListener (
60636069 "mousedown" ,
60646070 ( event ) => {
6071+ if ( ! this . isSelecting ) return ;
6072+ this . moving = false ;
60656073 // event.preventDefault();
60666074 // event.stopPropagation();
60676075 if ( event . target . id === "myCanvas" ) {
@@ -6082,6 +6090,12 @@ class Activity {
60826090 // end the drag on navbar
60836091 document . getElementById ( "toolbars" ) . addEventListener ( "mouseover" , ( ) => { this . isDragging = false ; } ) ;
60846092
6093+ this . selectMode = ( ) => {
6094+ this . moving = false ;
6095+ this . isSelecting = ! this . isSelecting ;
6096+ ( this . isSelecting ) ? this . textMsg ( _ ( "Select is enabled." ) ) : this . textMsg ( _ ( "Select is disabled." ) ) ;
6097+ }
6098+
60856099 this . _create2Ddrag = ( ) => {
60866100 this . dragArea = { } ;
60876101 this . selectedBlocks = [ ] ;
@@ -6099,7 +6113,7 @@ class Activity {
60996113 this . hasMouseMoved = true ;
61006114 // event.preventDefault();
61016115 // this.selectedBlocks = [];
6102- if ( this . isDragging ) {
6116+ if ( this . isDragging && this . isSelecting ) {
61036117 this . currentX = event . clientX ;
61046118 this . currentY = event . clientY ;
61056119 if ( ! this . blocks . isBlockMoving && ! this . turtles . running ( ) ) {
@@ -6114,6 +6128,7 @@ class Activity {
61146128
61156129 document . addEventListener ( "mouseup" , ( event ) => {
61166130 // event.preventDefault();
6131+ if ( ! this . isSelecting ) return ;
61176132 this . isDragging = false ;
61186133 this . selectionArea . style . display = "none" ;
61196134 this . startX = 0 ;
0 commit comments