mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Add red 'X' to mouse cursor if blocks are over toolbox.
This commit is contained in:
parent
3bc81bd543
commit
c9169285d9
6 changed files with 48 additions and 12 deletions
|
@ -907,7 +907,7 @@ Blockly.Workspace.prototype.traceOn=function(a){this.traceOn_=a;this.traceWrappe
|
|||
Blockly.Workspace.prototype.highlightBlock=function(a){this.traceOn_&&0!=Blockly.Block.dragMode_&&this.traceOn(!1);if(this.traceOn_){var b=null;if(a&&(b=this.getBlockById(a),!b))return;this.traceOn(!1);b?b.select():Blockly.selected&&Blockly.selected.unselect();var c=this;setTimeout(function(){c.traceOn(!0)},1)}};
|
||||
Blockly.Workspace.prototype.fireChangeEvent=function(){this.fireChangeEventPid_&&window.clearTimeout(this.fireChangeEventPid_);var a=this.svgBlockCanvas_;a&&(this.fireChangeEventPid_=window.setTimeout(function(){Blockly.fireUiEvent(a,"blocklyWorkspaceChange")},0))};
|
||||
Blockly.Workspace.prototype.paste=function(a){if(!(a.getElementsByTagName("block").length>=this.remainingCapacity())){var b=Blockly.Xml.domToBlock(this,a),c=parseInt(a.getAttribute("x"),10);a=parseInt(a.getAttribute("y"),10);if(!isNaN(c)&&!isNaN(a)){Blockly.RTL&&(c=-c);do for(var d=!1,e=this.getAllBlocks(),f=0,g;g=e[f];f++)g=g.getRelativeToSurfaceXY(),1>=Math.abs(c-g.x)&&1>=Math.abs(a-g.y)&&(c=Blockly.RTL?c-Blockly.SNAP_RADIUS:c+Blockly.SNAP_RADIUS,a+=2*Blockly.SNAP_RADIUS,d=!0);while(d);b.moveBy(c,
|
||||
a)}b.select()}};Blockly.Workspace.prototype.remainingCapacity=function(){return Infinity==this.maxBlocks?Infinity:this.maxBlocks-this.getAllBlocks().length};Blockly.Workspace.prototype.recordDeleteAreas=function(){this.deleteAreaTrash_=this.trashcan?this.trashcan.getRect():null;this.deleteAreaToolbox_=this.flyout_?this.flyout_.getRect():null};
|
||||
a)}b.select()}};Blockly.Workspace.prototype.remainingCapacity=function(){return Infinity==this.maxBlocks?Infinity:this.maxBlocks-this.getAllBlocks().length};Blockly.Workspace.prototype.recordDeleteAreas=function(){this.deleteAreaTrash_=this.trashcan?this.trashcan.getRect():null;this.deleteAreaToolbox_=this.flyout_?this.flyout_.getRect():this.toolbox_?this.toolbox_.getRect():null};
|
||||
Blockly.Workspace.prototype.isDeleteArea=function(a){a=Blockly.mouseToSvg(a);a=new goog.math.Coordinate(a.x,a.y);if(this.deleteAreaTrash_){if(this.deleteAreaTrash_.contains(a))return this.trashcan.setOpen_(!0),Blockly.Css.setCursor(Blockly.Css.Cursor.DELETE),!0;this.trashcan.setOpen_(!1)}if(this.deleteAreaToolbox_&&this.deleteAreaToolbox_.contains(a))return Blockly.Css.setCursor(Blockly.Css.Cursor.DELETE),!0;Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED);return!1};
|
||||
Blockly.Workspace.prototype.clear=Blockly.Workspace.prototype.clear;
|
||||
// Copyright 2012 Google Inc. Apache License 2.0
|
||||
|
@ -1042,7 +1042,7 @@ Blockly.Block.prototype.getHeightWidth=function(){var a=this.svg_.height,b=this.
|
|||
Blockly.Block.prototype.onMouseDown_=function(a){if(!this.isInFlyout){Blockly.svgResize();Blockly.terminateDrag_();this.select();Blockly.hideChaff();if(Blockly.isRightButton(a))this.showContextMenu_(a);else if(this.isMovable()){Blockly.removeAllRanges();Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED);var b=this.getRelativeToSurfaceXY();this.startDragX=b.x;this.startDragY=b.y;this.startDragMouseX=a.clientX;this.startDragMouseY=a.clientY;Blockly.Block.dragMode_=1;Blockly.Block.onMouseUpWrapper_=Blockly.bindEvent_(document,
|
||||
"mouseup",this,this.onMouseUp_);Blockly.Block.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMove_);this.draggedBubbles_=[];for(var b=this.getDescendants(),c=0,d;d=b[c];c++){d=d.getIcons();for(var e=0;e<d.length;e++){var f=d[e].getIconLocation();f.bubble=d[e];this.draggedBubbles_.push(f)}}}else return;a.stopPropagation()}};
|
||||
Blockly.Block.prototype.onMouseUp_=function(a){var b=this;Blockly.doCommand(function(){Blockly.terminateDrag_();if(Blockly.selected&&Blockly.highlightedConnection_)Blockly.localConnection_.connect(Blockly.highlightedConnection_),b.svg_&&(Blockly.localConnection_.isSuperior()?Blockly.highlightedConnection_:Blockly.localConnection_).sourceBlock_.svg_.connectionUiEffect(),b.workspace.trashcan&&b.workspace.trashcan.close();else if(b.workspace.isDeleteArea(a)){var c=b.workspace.trashcan;c&&goog.Timer.callOnce(c.close,
|
||||
100,c);Blockly.selected.dispose(!1,!0);Blockly.fireUiEvent(window,"resize")}Blockly.highlightedConnection_&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null)})};Blockly.Block.prototype.showHelp_=function(){var a=goog.isFunction(this.helpUrl)?this.helpUrl():this.helpUrl;a&&window.open(a)};
|
||||
100,c);Blockly.selected.dispose(!1,!0);Blockly.fireUiEvent(window,"resize")}Blockly.highlightedConnection_&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null);Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN)})};Blockly.Block.prototype.showHelp_=function(){var a=goog.isFunction(this.helpUrl)?this.helpUrl():this.helpUrl;a&&window.open(a)};
|
||||
Blockly.Block.prototype.duplicate_=function(){var a=Blockly.Xml.blockToDom_(this);Blockly.Xml.deleteNext(a);var a=Blockly.Xml.domToBlock(this.workspace,a),b=this.getRelativeToSurfaceXY();b.x=Blockly.RTL?b.x-Blockly.SNAP_RADIUS:b.x+Blockly.SNAP_RADIUS;b.y+=2*Blockly.SNAP_RADIUS;a.moveBy(b.x,b.y);a.select();return a};
|
||||
Blockly.Block.prototype.showContextMenu_=function(a){if(!Blockly.readOnly&&this.contextMenu){var b=this,c=[];if(this.isDeletable()&&this.isMovable()&&!b.isInFlyout){var d={text:Blockly.Msg.DUPLICATE_BLOCK,enabled:!0,callback:function(){b.duplicate_()}};this.getDescendants().length>this.workspace.remainingCapacity()&&(d.enabled=!1);c.push(d);this.isEditable()&&!this.collapsed_&&Blockly.comments&&(d={enabled:!0},this.comment?(d.text=Blockly.Msg.REMOVE_COMMENT,d.callback=function(){b.setCommentText(null)}):
|
||||
(d.text=Blockly.Msg.ADD_COMMENT,d.callback=function(){b.setCommentText("")}),c.push(d));if(!this.collapsed_)for(d=0;d<this.inputList.length;d++)if(this.inputList[d].type==Blockly.INPUT_VALUE){d={enabled:!0};d.text=this.inputsInline?Blockly.Msg.EXTERNAL_INPUTS:Blockly.Msg.INLINE_INPUTS;d.callback=function(){b.setInputsInline(!b.inputsInline)};c.push(d);break}Blockly.collapse&&(this.collapsed_?(d={enabled:!0},d.text=Blockly.Msg.EXPAND_BLOCK,d.callback=function(){b.setCollapsed(!1)}):(d={enabled:!0},
|
||||
|
@ -1224,18 +1224,19 @@ Blockly.Toolbox.prototype.CONFIG_={indentWidth:19,cssRoot:"blocklyTreeRoot",cssH
|
|||
Blockly.Toolbox.prototype.init=function(){this.CONFIG_.cleardotPath=Blockly.pathToMedia+"1x1.gif";this.CONFIG_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(Blockly.RTL?"Rtl":"Ltr");var a=new Blockly.Toolbox.TreeControl(this,this.CONFIG_);this.tree_=a;a.setShowRootNode(!1);a.setShowLines(!1);a.setShowExpandIcons(!1);a.setSelectedItem(null);this.HtmlDiv.style.display="block";this.flyout_.init(Blockly.mainWorkspace);this.populate_();a.render(this.HtmlDiv);var b=this;goog.events.listen(window,goog.events.EventType.RESIZE,
|
||||
function(){b.position_()});this.position_()};Blockly.Toolbox.prototype.position_=function(){var a=this.HtmlDiv,b=goog.style.getBorderBox(Blockly.svg),c=Blockly.svgSize();Blockly.RTL?(b=Blockly.convertCoordinates(0,0,!1),a.style.left=b.x+c.width-a.offsetWidth+"px"):a.style.marginLeft=b.left;a.style.height=c.height+1+"px";this.width=a.offsetWidth;Blockly.RTL||--this.width};
|
||||
Blockly.Toolbox.prototype.populate_=function(){function a(c,d){for(var e=0,f;f=c.childNodes[e];e++)if(f.tagName){var g=f.tagName.toUpperCase();if("CATEGORY"==g){g=b.createNode(f.getAttribute("name"));g.blocks=[];d.add(g);var h=f.getAttribute("custom");h?g.blocks=h:a(f,g)}else"HR"==g?d.add(new Blockly.Toolbox.TreeSeparator):"BLOCK"==g&&d.blocks.push(f)}}var b=this.tree_;b.removeChildren();b.blocks=[];a(Blockly.languageTree,this.tree_);if(b.blocks.length)throw"Toolbox cannot have both blocks and categories in the root level.";
|
||||
Blockly.fireUiEvent(window,"resize")};Blockly.Toolbox.prototype.clearSelection=function(){this.tree_.setSelectedItem(null)};Blockly.Toolbox.TreeControl=function(a,b){this.toolbox_=a;goog.ui.tree.TreeControl.call(this,goog.html.SafeHtml.EMPTY,b)};goog.inherits(Blockly.Toolbox.TreeControl,goog.ui.tree.TreeControl);
|
||||
Blockly.fireUiEvent(window,"resize")};Blockly.Toolbox.prototype.clearSelection=function(){this.tree_.setSelectedItem(null)};Blockly.Toolbox.prototype.getRect=function(){var a=Blockly.RTL?Blockly.svgSize().width-this.width:-1E7;return new goog.math.Rect(a,-1E7,1E7+this.width,2E7)};Blockly.Toolbox.TreeControl=function(a,b){this.toolbox_=a;goog.ui.tree.TreeControl.call(this,goog.html.SafeHtml.EMPTY,b)};goog.inherits(Blockly.Toolbox.TreeControl,goog.ui.tree.TreeControl);
|
||||
Blockly.Toolbox.TreeControl.prototype.enterDocument=function(){Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this);if(goog.events.BrowserFeature.TOUCH_ENABLED){var a=this.getElement();Blockly.bindEvent_(a,goog.events.EventType.TOUCHSTART,this,this.handleTouchEvent_)}};Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_=function(a){a.preventDefault();var b=this.getNodeFromEvent_(a);b&&a.type===goog.events.EventType.TOUCHSTART&&window.setTimeout(function(){b.onMouseDown(a)},1)};
|
||||
Blockly.Toolbox.TreeControl.prototype.createNode=function(a){return new Blockly.Toolbox.TreeNode(this.toolbox_,a?goog.html.SafeHtml.htmlEscape(a):goog.html.SafeHtml.EMPTY,this.getConfig(),this.getDomHelper())};Blockly.Toolbox.TreeControl.prototype.setSelectedItem=function(a){this.selectedItem_!=a&&(goog.ui.tree.TreeControl.prototype.setSelectedItem.call(this,a),a&&a.blocks&&a.blocks.length?this.toolbox_.flyout_.show(a.blocks):this.toolbox_.flyout_.hide())};
|
||||
Blockly.Toolbox.TreeNode=function(a,b,c,d){goog.ui.tree.TreeNode.call(this,b,c,d);a&&(b=function(){Blockly.fireUiEvent(window,"resize")},goog.events.listen(a.tree_,goog.ui.tree.BaseNode.EventType.EXPAND,b),goog.events.listen(a.tree_,goog.ui.tree.BaseNode.EventType.COLLAPSE,b))};goog.inherits(Blockly.Toolbox.TreeNode,goog.ui.tree.TreeNode);goog.ui.tree.BaseNode.prototype.getExpandIconSafeHtml=function(){return goog.html.SafeHtml.create("span")};
|
||||
Blockly.Toolbox.TreeNode.prototype.onMouseDown=function(a){this.hasChildren()&&this.isUserCollapsible_?(this.toggle(),this.select()):this.isSelected()?this.getTree().setSelectedItem(null):this.select();this.updateRow()};Blockly.Toolbox.TreeNode.prototype.onDoubleClick_=function(a){};Blockly.Toolbox.TreeSeparator=function(){Blockly.Toolbox.TreeNode.call(this,null,"",Blockly.Toolbox.TreeSeparator.CONFIG_)};goog.inherits(Blockly.Toolbox.TreeSeparator,Blockly.Toolbox.TreeNode);
|
||||
Blockly.Toolbox.TreeSeparator.CONFIG_={cssTreeRow:"blocklyTreeSeparator"};
|
||||
// Copyright 2013 Google Inc. Apache License 2.0
|
||||
Blockly.Css={};Blockly.Css.Cursor={OPEN:"handopen",CLOSED:"handclosed",DELETE:"handdelete"};Blockly.Css.currentCursor_="";Blockly.Css.styleSheet_=null;Blockly.Css.mediaPath_="";Blockly.Css.inject=function(){var a=Blockly.Css.CONTENT.join("\n");Blockly.Css.mediaPath_=Blockly.pathToMedia.replace(/[\\\/]$/,"");a=a.replace(/<<<PATH>>>/g,Blockly.Css.mediaPath_);goog.cssom.addCssText(a);a=goog.cssom.getAllCssStyleSheets();Blockly.Css.styleSheet_=a[a.length-1];Blockly.Css.setCursor("handopen")};
|
||||
Blockly.Css.setCursor=function(a){if(!Blockly.readOnly&&Blockly.Css.currentCursor_!=a){Blockly.Css.currentCursor_=a;var b="url("+Blockly.Css.mediaPath_+"/"+a+".cur) "+(a==Blockly.Css.Cursor.OPEN?"8 5":"7 3")+", auto";goog.cssom.replaceCssRule("",".blocklyDraggable {\n cursor: "+b+";\n}\n",Blockly.Css.styleSheet_,0);Blockly.svg&&(Blockly.svg.style.cursor=a==Blockly.Css.Cursor.OPEN?"":b)}};
|
||||
Blockly.Css.CONTENT=[".blocklyDraggable {","}",".blocklySvg {"," background-color: #fff;"," border: 1px solid #ddd;"," overflow: hidden;","}",".blocklyWidgetDiv {"," position: absolute;"," display: none;"," z-index: 999;","}",".blocklyResizeSE {"," fill: #aaa;"," cursor: se-resize;","}",".blocklyResizeSW {"," fill: #aaa;"," cursor: sw-resize;","}",".blocklyResizeLine {"," stroke-width: 1;"," stroke: #888;","}",".blocklyHighlightedConnectionPath {"," stroke-width: 4px;"," stroke: #fc3;",
|
||||
" fill: none;","}",".blocklyPathLight {"," fill: none;"," stroke-width: 2;"," stroke-linecap: round;","}",".blocklySelected>.blocklyPath {"," stroke-width: 3px;"," stroke: #fc3;","}",".blocklySelected>.blocklyPathLight {"," display: none;","}",".blocklyDragging>.blocklyPath,",".blocklyDragging>.blocklyPathLight {"," fill-opacity: .8;"," stroke-opacity: .8;","}",".blocklyDragging>.blocklyPathDark {"," display: none;","}",".blocklyDisabled>.blocklyPath {"," fill-opacity: .5;"," stroke-opacity: .5;",
|
||||
"}",".blocklyDisabled>.blocklyPathLight,",".blocklyDisabled>.blocklyPathDark {"," display: none;","}",".blocklyText {"," cursor: default;"," font-family: sans-serif;"," font-size: 11pt;"," fill: #fff;","}",".blocklyNonEditableText>text {"," pointer-events: none;","}",".blocklyNonEditableText>rect,",".blocklyEditableText>rect {"," fill: #fff;"," fill-opacity: .6;","}",".blocklyNonEditableText>text,",".blocklyEditableText>text {"," fill: #000;","}",".blocklyEditableText:hover>rect {"," stroke-width: 2;",
|
||||
Blockly.Css={};Blockly.Css.Cursor={OPEN:"handopen",CLOSED:"handclosed",DELETE:"handdelete"};Blockly.Css.currentCursor_="";Blockly.Css.styleSheet_=null;Blockly.Css.mediaPath_="";Blockly.Css.inject=function(){var a=Blockly.Css.CONTENT.join("\n");Blockly.Css.mediaPath_=Blockly.pathToMedia.replace(/[\\\/]$/,"");a=a.replace(/<<<PATH>>>/g,Blockly.Css.mediaPath_);goog.cssom.addCssText(a);a=goog.cssom.getAllCssStyleSheets();Blockly.Css.styleSheet_=a[a.length-1];Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN)};
|
||||
Blockly.Css.setCursor=function(a){if(!Blockly.readOnly&&Blockly.Css.currentCursor_!=a){Blockly.Css.currentCursor_=a;var b="url("+Blockly.Css.mediaPath_+"/"+a+".cur) "+(a==Blockly.Css.Cursor.OPEN?"8 5":"7 3")+", auto";goog.cssom.replaceCssRule("",".blocklyDraggable {\n cursor: "+b+";\n}\n",Blockly.Css.styleSheet_,0);for(var c=document.getElementsByClassName("blocklyToolboxDiv"),d=0,e;e=c[d];d++)e.style.cursor=a==Blockly.Css.Cursor.OPEN?"":b;Blockly.svg&&(Blockly.svg.style.cursor=a==Blockly.Css.Cursor.OPEN?
|
||||
"":b)}};
|
||||
Blockly.Css.CONTENT=[".blocklyDraggable {","}",".blocklySvg {"," background-color: #fff;"," border: 1px solid #ddd;"," overflow: hidden;","}",".blocklyWidgetDiv {"," position: absolute;"," display: none;"," z-index: 999;","}",".blocklyResizeSE {"," fill: #aaa;"," cursor: se-resize;","}",".blocklyResizeSW {"," fill: #aaa;"," cursor: sw-resize;","}",".blocklyResizeLine {"," stroke-width: 1;"," stroke: #888;","}",".blocklyHighlightedConnectionPath {"," stroke-width: 4px;"," stroke: #fc3;"," fill: none;",
|
||||
"}",".blocklyPathLight {"," fill: none;"," stroke-width: 2;"," stroke-linecap: round;","}",".blocklySelected>.blocklyPath {"," stroke-width: 3px;"," stroke: #fc3;","}",".blocklySelected>.blocklyPathLight {"," display: none;","}",".blocklyDragging>.blocklyPath,",".blocklyDragging>.blocklyPathLight {"," fill-opacity: .8;"," stroke-opacity: .8;","}",".blocklyDragging>.blocklyPathDark {"," display: none;","}",".blocklyDisabled>.blocklyPath {"," fill-opacity: .5;"," stroke-opacity: .5;","}",
|
||||
".blocklyDisabled>.blocklyPathLight,",".blocklyDisabled>.blocklyPathDark {"," display: none;","}",".blocklyText {"," cursor: default;"," font-family: sans-serif;"," font-size: 11pt;"," fill: #fff;","}",".blocklyNonEditableText>text {"," pointer-events: none;","}",".blocklyNonEditableText>rect,",".blocklyEditableText>rect {"," fill: #fff;"," fill-opacity: .6;","}",".blocklyNonEditableText>text,",".blocklyEditableText>text {"," fill: #000;","}",".blocklyEditableText:hover>rect {"," stroke-width: 2;",
|
||||
" stroke: #fff;","}",".blocklyBubbleText {"," fill: #000;","}",".blocklySvg text {"," -moz-user-select: none;"," -webkit-user-select: none;"," user-select: none;"," cursor: inherit;","}",".blocklyHidden {"," display: none;","}",".blocklyFieldDropdown:not(.blocklyHidden) {"," display: block;","}",".blocklyTooltipBackground {"," fill: #ffffc7;"," stroke-width: 1px;"," stroke: #d8d8d8;","}",".blocklyTooltipShadow,",".blocklyDropdownMenuShadow {"," fill: #bbb;"," filter: url(#blocklyShadowFilter);",
|
||||
"}",".blocklyTooltipText {"," font-family: sans-serif;"," font-size: 9pt;"," fill: #000;","}",".blocklyIconShield {"," cursor: default;"," fill: #00c;"," stroke-width: 1px;"," stroke: #ccc;","}",".blocklyIconGroup:hover>.blocklyIconShield {"," fill: #00f;"," stroke: #fff;","}",".blocklyIconGroup:hover>.blocklyIconMark {"," fill: #fff;","}",".blocklyIconMark {"," cursor: default !important;"," font-family: sans-serif;"," font-size: 9pt;"," font-weight: bold;"," fill: #ccc;"," text-anchor: middle;",
|
||||
"}",".blocklyWarningBody {","}",".blocklyMinimalBody {"," margin: 0;"," padding: 0;","}",".blocklyCommentTextarea {"," margin: 0;"," padding: 2px;"," border: 0;"," resize: none;"," background-color: #ffc;","}",".blocklyHtmlInput {"," font-family: sans-serif;"," font-size: 11pt;"," border: none;"," outline: none;"," width: 100%","}",".blocklyMutatorBackground {"," fill: #fff;"," stroke-width: 1;"," stroke: #ddd;","}",".blocklyFlyoutBackground {"," fill: #ddd;"," fill-opacity: .8;",
|
||||
|
|
|
@ -54,7 +54,7 @@ goog.addDependency("../../../" + dir + "/core/procedures.js", ['Blockly.Procedur
|
|||
goog.addDependency("../../../" + dir + "/core/realtime-client-utils.js", ['rtclient'], []);
|
||||
goog.addDependency("../../../" + dir + "/core/realtime.js", ['Blockly.Realtime'], ['goog.array', 'goog.dom', 'goog.style', 'rtclient']);
|
||||
goog.addDependency("../../../" + dir + "/core/scrollbar.js", ['Blockly.Scrollbar', 'Blockly.ScrollbarPair'], ['goog.userAgent']);
|
||||
goog.addDependency("../../../" + dir + "/core/toolbox.js", ['Blockly.Toolbox'], ['Blockly.Flyout', 'goog.events.BrowserFeature', 'goog.html.SafeHtml', 'goog.style', 'goog.ui.tree.TreeControl', 'goog.ui.tree.TreeNode']);
|
||||
goog.addDependency("../../../" + dir + "/core/toolbox.js", ['Blockly.Toolbox'], ['Blockly.Flyout', 'goog.events.BrowserFeature', 'goog.html.SafeHtml', 'goog.style', 'goog.ui.tree.TreeControl', 'goog.ui.tree.TreeNode', 'goog.math.Rect']);
|
||||
goog.addDependency("../../../" + dir + "/core/tooltip.js", ['Blockly.Tooltip'], []);
|
||||
goog.addDependency("../../../" + dir + "/core/trashcan.js", ['Blockly.Trashcan'], ['goog.math', 'goog.math.Rect', 'goog.Timer']);
|
||||
goog.addDependency("../../../" + dir + "/core/utils.js", ['Blockly.utils'], []);
|
||||
|
|
|
@ -592,6 +592,7 @@ Blockly.Block.prototype.onMouseUp_ = function(e) {
|
|||
Blockly.highlightedConnection_.unhighlight();
|
||||
Blockly.highlightedConnection_ = null;
|
||||
}
|
||||
Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN);
|
||||
});
|
||||
};
|
||||
|
||||
|
|
17
core/css.js
17
core/css.js
|
@ -74,7 +74,7 @@ Blockly.Css.inject = function() {
|
|||
goog.cssom.addCssText(text);
|
||||
var sheets = goog.cssom.getAllCssStyleSheets();
|
||||
Blockly.Css.styleSheet_ = sheets[sheets.length - 1];
|
||||
Blockly.Css.setCursor('handopen');
|
||||
Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -98,11 +98,22 @@ Blockly.Css.setCursor = function(cursor) {
|
|||
}
|
||||
var url = 'url(' + Blockly.Css.mediaPath_ + '/' + cursor +
|
||||
'.cur) ' + xy + ', auto';
|
||||
// There are potentially hundreds of draggable objects. Changing their style
|
||||
// properties individually is too slow, so change the CSS rule instead.
|
||||
var rule = '.blocklyDraggable {\n cursor: ' + url + ';\n}\n';
|
||||
goog.cssom.replaceCssRule('', rule, Blockly.Css.styleSheet_, 0);
|
||||
// There is probably only one toolbox, so just change its style property.
|
||||
var toolboxen = document.getElementsByClassName('blocklyToolboxDiv');
|
||||
for (var i = 0, toolbox; toolbox = toolboxen[i]; i++) {
|
||||
if (cursor == Blockly.Css.Cursor.OPEN) {
|
||||
toolbox.style.cursor = '';
|
||||
} else {
|
||||
toolbox.style.cursor = url;
|
||||
}
|
||||
}
|
||||
// Set cursor on the SVG surface as well, so that rapid movements
|
||||
// don't result in cursor changing to an arrow momentarily.
|
||||
if (Blockly.svg) {
|
||||
// Set cursor on the SVG surface as well, so that rapid movements
|
||||
// don't result in cursor changing to an arrow momentarily.
|
||||
if (cursor == Blockly.Css.Cursor.OPEN) {
|
||||
Blockly.svg.style.cursor = '';
|
||||
} else {
|
||||
|
|
|
@ -32,6 +32,7 @@ goog.require('goog.html.SafeHtml');
|
|||
goog.require('goog.style');
|
||||
goog.require('goog.ui.tree.TreeControl');
|
||||
goog.require('goog.ui.tree.TreeNode');
|
||||
goog.require('goog.math.Rect');
|
||||
|
||||
|
||||
/**
|
||||
|
@ -197,6 +198,26 @@ Blockly.Toolbox.prototype.clearSelection = function() {
|
|||
this.tree_.setSelectedItem(null);
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the deletion rectangle for this toolbar.
|
||||
* @return {goog.math.Rect} Rectangle in which to delete.
|
||||
*/
|
||||
Blockly.Toolbox.prototype.getRect = function() {
|
||||
// BIG_NUM is offscreen padding so that blocks dragged beyond the toolbox
|
||||
// area are still deleted. Must be smaller than Infinity, but larger than
|
||||
// the largest screen size.
|
||||
var BIG_NUM = 10000000;
|
||||
// Assumes that the toolbox is on the SVG edge. If this changes
|
||||
// (e.g. toolboxes in mutators) then this code will need to be more complex.
|
||||
if (Blockly.RTL) {
|
||||
var svgSize = Blockly.svgSize();
|
||||
var x = svgSize.width - this.width;
|
||||
} else {
|
||||
var x = -BIG_NUM;
|
||||
}
|
||||
return new goog.math.Rect(x, -BIG_NUM, BIG_NUM + this.width, 2 * BIG_NUM);
|
||||
};
|
||||
|
||||
// Extending Closure's Tree UI.
|
||||
|
||||
/**
|
||||
|
|
|
@ -412,6 +412,8 @@ Blockly.Workspace.prototype.recordDeleteAreas = function() {
|
|||
}
|
||||
if (this.flyout_) {
|
||||
this.deleteAreaToolbox_ = this.flyout_.getRect();
|
||||
} else if (this.toolbox_) {
|
||||
this.deleteAreaToolbox_ = this.toolbox_.getRect();
|
||||
} else {
|
||||
this.deleteAreaToolbox_ = null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue