Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 3a599e64 rédigé par Christophe DECLERCQ's avatar Christophe DECLERCQ
Parcourir les fichiers

Création de nouveaux blocs par copie des blocs du flyout pour les variables

parent 0d2ca80d
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -771,10 +771,10 @@ Blockly.WidgetDiv.positionWithAnchor=function(a,b,c,d){var e=Blockly.WidgetDiv.c
Blockly.WidgetDiv.calculateY_=function(a,b,c){return b.bottom+c.height>=a.bottom?b.top-c.height:b.bottom};Blockly.VERSION="3.20200123.1";Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.draggingConnections=[];Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.clipboardTypeCounts_=null;Blockly.cache3dSupported_=null;Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};Blockly.resizeSvgContents=function(a){a.resizeContents()};
Blockly.svgResize=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.getParentSvg(),c=b.parentNode;if(c){var d=c.offsetWidth;c=c.offsetHeight;b.cachedWidth_!=d&&(b.setAttribute("width",d+"px"),b.cachedWidth_=d);b.cachedHeight_!=c&&(b.setAttribute("height",c+"px"),b.cachedHeight_=c);a.resize()}};
Blockly.onKeyDown=function(a){var b=Blockly.mainWorkspace;if(b&&!(Blockly.utils.isTargetInput(a)||b.rendered&&!b.isVisible()))if(b.options.readOnly)Blockly.navigation.onKeyPress(a);else{var c=!1,d=Blockly.selected;if(a.keyCode==Blockly.utils.KeyCodes.ESC)Blockly.hideChaff(),Blockly.navigation.onBlocklyAction(Blockly.navigation.ACTION_EXIT);else if(Blockly.navigation.onKeyPress(a))return;if(d&&d.isInFlyout&&Blockly.mainWorkspace.flyout_){c=Blockly.mainWorkspace.flyout_;var e;for(b=0;b<c.mats_.length;b++)c.mats_[b]&&
c.mats_[b].tooltip==d&&(e=b);if(1<=e&&a.keyCode===Blockly.utils.KeyCodes.UP){c.mats_[e].tooltip.unselect();for(a=1;0<=e-a&&!c.mats_[e-a];)a++;c.mats_[e-a].tooltip.select()}else if(e<c.mats_.length-1&&a.keyCode===Blockly.utils.KeyCodes.DOWN){c.mats_[e].tooltip.unselect();for(a=1;e+a<c.mats_.length&&!c.mats_[e+a];)a++;c.mats_[e+a].tooltip.select()}else a.keyCode===Blockly.utils.KeyCodes.ENTER&&(a=Blockly.mainWorkspace.newBlock(Blockly.selected.type),c.mats_[e].tooltip.unselect(),a.initSvg(),a.moveBy(50,
20),a.render(),a.select())}else if(Blockly.mainWorkspace.getToolbox()&&Blockly.selected&&Blockly.selected.isInFlyout){e=-1;d=Blockly.mainWorkspace.getToolbox();c=d.getFlyout();for(b=0;b<c.mats_.length;b++)c.mats_[b]&&c.mats_[b].tooltip==Blockly.selected&&(e=b);if(a.keyCode===(Blockly.mainWorkspace.RTL?Blockly.utils.KeyCodes.LEFT:Blockly.utils.KeyCodes.RIGHT)){for(d.lastCategory_.selectNext();!d.lastCategory_.blocks;)d.lastCategory_.selectNext();d.getFlyout().mats_[0].tooltip.select()}else if(a.keyCode===
c.mats_[b].tooltip==d&&(e=b);if(1<=e&&a.keyCode===Blockly.utils.KeyCodes.UP){c.mats_[e].tooltip.unselect();for(a=1;0<=e-a&&!c.mats_[e-a];)a++;c.mats_[e-a].tooltip.select()}else if(e<c.mats_.length-1&&a.keyCode===Blockly.utils.KeyCodes.DOWN){c.mats_[e].tooltip.unselect();for(a=1;e+a<c.mats_.length&&!c.mats_[e+a];)a++;c.mats_[e+a].tooltip.select()}else a.keyCode===Blockly.utils.KeyCodes.ENTER&&(a=Blockly.mainWorkspace.getFlyout().createBlock(Blockly.selected),c.mats_[e].tooltip.unselect(),a.initSvg(),
a.moveBy(50,20),a.render(),a.select())}else if(Blockly.mainWorkspace.getToolbox()&&Blockly.selected&&Blockly.selected.isInFlyout){e=-1;d=Blockly.mainWorkspace.getToolbox();c=d.getFlyout();for(b=0;b<c.mats_.length;b++)c.mats_[b]&&c.mats_[b].tooltip==Blockly.selected&&(e=b);if(a.keyCode===(Blockly.mainWorkspace.RTL?Blockly.utils.KeyCodes.LEFT:Blockly.utils.KeyCodes.RIGHT)){for(d.lastCategory_.selectNext();!d.lastCategory_.blocks;)d.lastCategory_.selectNext();d.getFlyout().mats_[0].tooltip.select()}else if(a.keyCode===
(Blockly.mainWorkspace.RTL?Blockly.utils.KeyCodes.RIGHT:Blockly.utils.KeyCodes.LEFT)){for(d.lastCategory_.selectPrevious();!d.lastCategory_.blocks;)d.lastCategory_.selectPrevious();d.getFlyout().mats_[0].tooltip.select()}else if(0<=e&&e<c.mats_.length-1&&a.keyCode===Blockly.utils.KeyCodes.DOWN){c.mats_[e].tooltip.unselect();for(a=1;e+a<c.mats_.length&&!c.mats_[e+a];)a++;c.mats_[e+a].tooltip.select()}else if(1<=e&&a.keyCode===Blockly.utils.KeyCodes.UP){c.mats_[e].tooltip.unselect();for(a=1;0<=e-a&&
!c.mats_[e-a];)a++;c.mats_[e-a].tooltip.select()}else(!(0<=e)||a.keyCode!==Blockly.utils.KeyCodes.DOWN&&a.keyCode!==Blockly.utils.KeyCodes.UP)&&0<=e&&a.keyCode===Blockly.utils.KeyCodes.ENTER&&(a=Blockly.mainWorkspace.newBlock(Blockly.selected.type),c.mats_[e].tooltip.unselect(),a.initSvg(),a.moveBy(50,20),a.render(),c.hide(),Blockly.mainWorkspace.getToolbox().clearSelection(),a.select())}else{if(d){var f=d.svgGroup_.getBoundingClientRect();e=f.x+50}else f=Blockly.mainWorkspace.svgGroup_.getBoundingClientRect(),
!c.mats_[e-a];)a++;c.mats_[e-a].tooltip.select()}else(!(0<=e)||a.keyCode!==Blockly.utils.KeyCodes.DOWN&&a.keyCode!==Blockly.utils.KeyCodes.UP)&&0<=e&&a.keyCode===Blockly.utils.KeyCodes.ENTER&&(a=Blockly.mainWorkspace.getFlyout().createBlock(Blockly.selected),c.mats_[e].tooltip.unselect(),a.initSvg(),a.moveBy(50,20),a.render(),c.hide(),Blockly.mainWorkspace.getToolbox().clearSelection(),a.select())}else{if(d){var f=d.svgGroup_.getBoundingClientRect();e=f.x+50}else f=Blockly.mainWorkspace.svgGroup_.getBoundingClientRect(),
e=f.x+200;f=f.y+20;if(d&&a.keyCode===(d.RTL?Blockly.utils.KeyCodes.RIGHT:Blockly.utils.KeyCodes.LEFT))Blockly.selectParentBlock();else if(d&&a.keyCode===(d.RTL?Blockly.utils.KeyCodes.LEFT:Blockly.utils.KeyCodes.RIGHT))Blockly.selectChildBlock();else if(d&&a.keyCode===Blockly.utils.KeyCodes.UP)Blockly.selectPrevBlock();else if(d&&a.keyCode===Blockly.utils.KeyCodes.DOWN)Blockly.selectNextBlock();else if(!d&&(a.keyCode===Blockly.utils.KeyCodes.UP||a.keyCode===Blockly.utils.KeyCodes.RIGHT||a.keyCode===
Blockly.utils.KeyCodes.DOWN||a.keyCode===Blockly.utils.KeyCodes.LEFT))a=Blockly.mainWorkspace.getTopBlocks(),a[0]&&a[0].select();else if(d&&a.keyCode===Blockly.utils.KeyCodes.INSERT)Blockly.hideChaff(),Blockly.selected.showContextMenu(new MouseEvent("mousedown",{clientX:e,clientY:f}));else if(!d&&a.keyCode===Blockly.utils.KeyCodes.INSERT&&0==Blockly.mainWorkspace.getTopBlocks().length)Blockly.hideChaff(),Blockly.mainWorkspace.showContextMenu(new MouseEvent("mousedown",{clientX:e,clientY:f}));else if(a.keyCode==
Blockly.utils.KeyCodes.BACKSPACE||a.keyCode==Blockly.utils.KeyCodes.DELETE){a.preventDefault();if(Blockly.Gesture.inProgress())return;Blockly.selected&&Blockly.selected.isDeletable()&&(c=!0)}else if(a.altKey||a.ctrlKey||a.metaKey){if(Blockly.Gesture.inProgress())return;Blockly.selected&&Blockly.selected.isDeletable()&&Blockly.selected.isMovable()&&(a.keyCode==Blockly.utils.KeyCodes.C?(Blockly.hideChaff(),Blockly.copy_(Blockly.selected)):a.keyCode!=Blockly.utils.KeyCodes.X||Blockly.selected.workspace.isFlyout||
......
......@@ -235,7 +235,8 @@ Blockly.onKeyDown = function(e) {
flyout.mats_[s+ds].tooltip.select();
}
else if (e.keyCode === Blockly.utils.KeyCodes.ENTER) {
var nb = Blockly.mainWorkspace.newBlock(Blockly.selected.type);
var nb = Blockly.mainWorkspace.getFlyout().createBlock(Blockly.selected);
// var nb = Blockly.mainWorkspace.newBlock(Blockly.selected.type);
flyout.mats_[s].tooltip.unselect();
nb.initSvg();
nb.moveBy(50,20);
......@@ -295,7 +296,8 @@ Blockly.onKeyDown = function(e) {
e.keyCode===(Blockly.utils.KeyCodes.UP))){
}
else if (s>=0 && e.keyCode===(Blockly.utils.KeyCodes.ENTER)) {
var nb = Blockly.mainWorkspace.newBlock(Blockly.selected.type);
// var nb = Blockly.mainWorkspace.newBlock(Blockly.selected.type);
var nb = Blockly.mainWorkspace.getFlyout().createBlock(Blockly.selected);
flyout.mats_[s].tooltip.unselect();
nb.initSvg();
nb.moveBy(50,20);
......
{
"@metadata": {
"author": "Ellen Spertus <ellen.spertus@gmail.com>",
"lastupdated": "2020-03-26 23:39:45.644863",
"lastupdated": "2020-03-30 17:29:34.451773",
"locale": "en",
"messagedocumentation" : "qqq"
},
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter