@@ -38,7 +38,15 @@ export default class DevTools {
3838 async init ( ) {
3939 this . addContextMenus ( ) ;
4040 while ( true ) {
41- const root = await this . addon . tab . waitForElement ( "ul[class*=gui_tab-list_]" , { markAsSeen : true } ) ;
41+ const root = await this . addon . tab . waitForElement ( "ul[class*=gui_tab-list_]" , {
42+ markAsSeen : true ,
43+ reduxEvents : [
44+ "scratch-gui/mode/SET_PLAYER" ,
45+ "fontsLoaded/SET_FONTS_LOADED" ,
46+ "scratch-gui/locales/SELECT_LOCALE" ,
47+ ] ,
48+ reduxCondition : ( state ) => ! state . scratchGui . mode . isPlayerOnly ,
49+ } ) ;
4250 this . initInner ( root ) ;
4351 }
4452 }
@@ -231,7 +239,7 @@ export default class DevTools {
231239 let myBlocks = [ ] ;
232240 let myBlocksByProcCode = { } ;
233241
234- // todo - get blockyly from an svg???
242+ // todo - get blockly from an svg???
235243
236244 let wksp = this . utils . getWorkspace ( ) ;
237245 let topBlocks = wksp . getTopBlocks ( ) ;
@@ -272,14 +280,18 @@ export default class DevTools {
272280
273281 for ( const root of topBlocks ) {
274282 if ( root . type === "procedures_definition" ) {
275- let fields = root . inputList [ 0 ] ;
276- let typeDesc = fields . fieldRow [ 0 ] . getText ( ) ;
277- let label = root . getChildren ( ) [ 0 ] ;
278- let procCode = label . getProcCode ( ) ;
283+ const label = root . getChildren ( ) [ 0 ] ;
284+ const procCode = label . getProcCode ( ) ;
279285 if ( ! procCode ) {
280286 continue ;
281287 }
282- addBlock ( "define" , typeDesc + " " + procCode , root ) ;
288+ const indexOfLabel = root . inputList . findIndex ( ( i ) => i . fieldRow . length > 0 ) ;
289+ if ( indexOfLabel === - 1 ) {
290+ continue ;
291+ }
292+ const translatedDefine = root . inputList [ indexOfLabel ] . fieldRow [ 0 ] . getText ( ) ;
293+ const message = indexOfLabel === 0 ? `${ translatedDefine } ${ procCode } ` : `${ procCode } ${ translatedDefine } ` ;
294+ addBlock ( "define" , message , root ) ;
283295 continue ;
284296 }
285297
@@ -618,7 +630,7 @@ export default class DevTools {
618630 }
619631
620632 /**
621- * Badly Ophaned - might want to delete these!
633+ * Badly Orphaned - might want to delete these!
622634 * @param topBlock
623635 * @returns {boolean }
624636 */
@@ -808,7 +820,7 @@ export default class DevTools {
808820 }
809821
810822 /**
811- * Find all the evern broadcasters.
823+ * Find all the event broadcasters.
812824 * @return {[{eventName:string, block:Block}] } Array of event names and blocks.
813825 */
814826 getCallsToEvents ( ) {
@@ -1501,8 +1513,18 @@ export default class DevTools {
15011513 }
15021514
15031515 if ( this . floatInp && ! e . target . closest ( "#s3devIDDOut" ) ) {
1504- // If we click outside the dropdown, then instigate the hide code...
1505- this . hideFloatDropDown ( ) ;
1516+ if (
1517+ ! e . shiftKey ||
1518+ // Clicking on the code area should always make multi-inject work
1519+ ( ! document . getElementsByClassName ( "injectionDiv" ) [ 0 ] . contains ( e . target ) &&
1520+ // Focused inputs are not part of the injectionDiv, but to the user they are part of the code area so make multi-inject work there
1521+ ! e . target . classList . contains ( "blocklyHtmlInput" ) ) ||
1522+ // This selector targets workspace buttons (Make a Block etc.) and the extension (!) buttons, which most commonly trigger a popup window so always close the dropdown
1523+ e . target . matches ( ".blocklyFlyoutButton, .blocklyFlyoutButton *, .blocklyTouchTargetBackground" )
1524+ ) {
1525+ // If we click outside the dropdown, then instigate the hide code...
1526+ this . hideFloatDropDown ( ) ;
1527+ }
15061528 }
15071529
15081530 if ( e . button === 1 || e . shiftKey ) {
@@ -2033,13 +2055,20 @@ export default class DevTools {
20332055 } else {
20342056 field . innerText = option . option [ 1 ] ; // griffpatch - oops! option.option[1] not 0?
20352057 }
2058+
2059+ // Handle "stop other scripts in sprite"
2060+ if ( option . option [ 1 ] === "other scripts in sprite" ) {
2061+ option . dom . querySelector ( "mutation" ) . setAttribute ( "hasnext" , "true" ) ;
2062+ }
20362063 }
20372064
20382065 x . appendChild ( option . dom ) ;
20392066
20402067 let ids = Blockly . Xml . domToWorkspace ( x , wksp ) ;
20412068
2042- this . reallyHideFloatDropDown ( true ) ;
2069+ if ( ! e . shiftKey ) {
2070+ this . reallyHideFloatDropDown ( true ) ;
2071+ }
20432072
20442073 let block = wksp . getBlockById ( ids [ 0 ] ) ;
20452074
@@ -2053,7 +2082,11 @@ export default class DevTools {
20532082 }
20542083 }
20552084
2056- this . domHelpers . triggerDragAndDrop ( block . svgPath_ , null , { x : this . mouseXY . x , y : this . mouseXY . y } ) ;
2085+ this . domHelpers . triggerDragAndDrop ( block . svgPath_ , null , { x : this . mouseXY . x , y : this . mouseXY . y } , e . shiftKey ) ;
2086+
2087+ if ( e . shiftKey ) {
2088+ document . getElementById ( "s3devIInp" ) . focus ( ) ;
2089+ }
20572090
20582091 this . blockCursor = block ;
20592092 }
0 commit comments