diff --git a/HISTORY.md b/HISTORY.md index b3c51b09..bc0d28fc 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -5,6 +5,7 @@ ### 2020-07-15 * morphic: made keyboard handler (more) invisible, thanks, Bernat! * gui: made remaining synchronous http requests asynch (url: #open, #run) +* morphic, gui: switch to scripts tab when dragging a block into the editor pane ### 2020-07-13 * paint, symbols: new iconic buttons for grow, shrink and flip actions, thanks, Jadga! diff --git a/src/gui.js b/src/gui.js index 9b1df4cc..3c855d58 100644 --- a/src/gui.js +++ b/src/gui.js @@ -1624,6 +1624,12 @@ IDE_Morph.prototype.createSpriteEditor = function () { this.spriteEditor.acceptsDrops = false; this.spriteEditor.contents.acceptsDrops = false; + + this.spriteEditor.contents.mouseEnterDragging = (morph) => { + if (morph instanceof BlockMorph) { + this.spriteBar.tabBar.tabTo('scripts'); + } + } } else if (this.currentTab === 'sounds') { this.spriteEditor = new JukeboxMorph( this.currentSprite, @@ -1634,6 +1640,12 @@ IDE_Morph.prototype.createSpriteEditor = function () { this.spriteEditor.updateSelection(); this.spriteEditor.acceptDrops = false; this.spriteEditor.contents.acceptsDrops = false; + + this.spriteEditor.contents.mouseEnterDragging = (morph) => { + if (morph instanceof BlockMorph) { + this.spriteBar.tabBar.tabTo('scripts'); + } + } } else { this.spriteEditor = new Morph(); this.spriteEditor.color = this.groupColor; diff --git a/src/morphic.js b/src/morphic.js index 00de3a01..b4a57989 100644 --- a/src/morphic.js +++ b/src/morphic.js @@ -302,7 +302,7 @@ ------------------- If you wish to create a web page with more than one world, make sure to prevent each world from auto-filling the whole page and - include it in the main loop. It's also a good idea to give each + include it in the main loop. It's also a good idea to give each world its own tabindex: example html file: @@ -479,7 +479,7 @@ MyMorph.prototype.mouseMove = function(pos) {}; - All of these methods have as optional parameter a Point object + Most of these methods have as optional parameter a Point object indicating the current position of the Hand inside the World's coordinate system. The @@ -489,6 +489,14 @@ currently pressed mouse button, which is either 'left' or 'right'. You can use this to let users interact with 3D environments. + The + + mouseEnterDragging(morph) + mouseLeaveDragging(morph) + + event methods have as optional parameter the morph currently dragged by + the Hand, if any. + Events may be "bubbled" up a morph's owner chain by calling this.escalateEvent(functionName, arg) @@ -11423,7 +11431,7 @@ HandMorph.prototype.processMouseMove = function (event) { old.mouseLeave(); } if (old.mouseLeaveDragging && this.mouseButton) { - old.mouseLeaveDragging(); + old.mouseLeaveDragging(this.children[0]); } } }); @@ -11433,7 +11441,7 @@ HandMorph.prototype.processMouseMove = function (event) { newMorph.mouseEnter(); } if (newMorph.mouseEnterDragging && this.mouseButton) { - newMorph.mouseEnterDragging(); + newMorph.mouseEnterDragging(this.children[0]); } }