File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ export class KeyboardNavigation {
2929 navigationController . setHasAutoNavigationEnabled ( true ) ;
3030 navigationController . listShortcuts ( ) ;
3131
32+ this . setGlowTheme ( ) ;
3233 installCursor ( workspace . getMarkerManager ( ) ) ;
3334
3435 // Ensure that only the root SVG group has a tab index.
@@ -41,4 +42,21 @@ export class KeyboardNavigation {
4142 navigationController . setHasFocus ( false ) ;
4243 } ) ;
4344 }
45+
46+ /**
47+ * Update the theme to match the selected glow colour to the cursor
48+ * colour.
49+ */
50+ setGlowTheme ( ) {
51+ const newTheme = Blockly . Theme . defineTheme ( 'zelosDerived' ,
52+ {
53+ name : 'zelosDerived' ,
54+ base : Blockly . Themes . Zelos ,
55+ componentStyles : {
56+ selectedGlowColour : '#ffa200' ,
57+ }
58+ }
59+ ) ;
60+ this . workspace . setTheme ( newTheme ) ;
61+ }
4462}
Original file line number Diff line number Diff line change @@ -409,6 +409,35 @@ export class LineCursor extends Marker {
409409 }
410410 return this . getRightMostChild ( newNode ) ;
411411 }
412+
413+ /**
414+ * Set the location of the marker and call the update method.
415+ * Setting isStack to true will only work if the newLocation is the top most
416+ * output or previous connection on a stack.
417+ *
418+ * Overrides drawing logic to call `setSelected` if the location is
419+ * a block, for testing on October 28 2024.
420+ *
421+ * @param newNode The new location of the marker.
422+ */
423+ setCurNode ( newNode : ASTNode ) {
424+ const oldNode = ( this as any ) . curNode ;
425+ ( this as any ) . curNode = newNode ;
426+ const drawer = ( this as any ) . drawer ;
427+ if ( newNode ?. getType ( ) == ASTNode . types . BLOCK ) {
428+ if ( drawer ) {
429+ drawer . hide ( ) ;
430+ }
431+ const block = newNode . getLocation ( ) as Blockly . BlockSvg ;
432+ Blockly . common . setSelected ( block ) ;
433+ } else if ( drawer ) {
434+ if ( oldNode ?. getType ( ) == ASTNode . types . BLOCK ) {
435+ Blockly . common . setSelected ( null ) ;
436+ }
437+
438+ drawer . draw ( oldNode , newNode ) ;
439+ }
440+ }
412441}
413442
414443export const registrationName = 'LineCursor' ;
You can’t perform that action at this time.
0 commit comments