File tree Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Expand file tree Collapse file tree 3 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -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
@@ -492,7 +495,7 @@ class Activity {
492495 ( event ) => {
493496 event . preventDefault ( ) ;
494497 event . stopPropagation ( ) ;
495- if ( ! this . beginnerMode ) {
498+ if ( ! this . beginnerMode && ! this . isSelecting ) {
496499 if ( event . target . id === "myCanvas" ) {
497500 this . _displayHelpfulWheel ( event ) ;
498501 }
@@ -6101,7 +6104,7 @@ class Activity {
61016104 this . hasMouseMoved = true ;
61026105 // event.preventDefault();
61036106 // this.selectedBlocks = [];
6104- if ( this . isDragging ) {
6107+ if ( this . isDragging && this . isSelecting ) {
61056108 this . currentX = event . clientX ;
61066109 this . currentY = event . clientY ;
61076110 if ( ! this . blocks . isBlockMoving && ! this . turtles . running ( ) ) {
Original file line number Diff line number Diff line change @@ -577,6 +577,7 @@ 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
580581 this . collapse = null ;
581582 this . expand = null ;
582583
@@ -871,6 +872,26 @@ Turtles.TurtlesView = class {
871872 this . activity . refreshCanvas ( ) ;
872873 } ;
873874
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+
874895 /**
875896 * Makes 'cartesian' button by initailising 'CARTESIANBUTTON' SVG.
876897 * Assigns click listener function to doGrid() method.
@@ -1170,6 +1191,7 @@ Turtles.TurtlesView = class {
11701191 __makeExpandButton ( ) ;
11711192 __makeClearButton ( ) ;
11721193 __makeGridButton ( ) ;
1194+ __makeSelectButton ( ) ;
11731195 jQuery . noConflict ( ) ( ".tooltipped" ) . each ( function ( ) {
11741196 jQuery . noConflict ( ) ( this ) . tooltip (
11751197 {
You can’t perform that action at this time.
0 commit comments