mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-10 21:18:53 -04:00
Disable events while workspace comment is getting created and moved. Fire CommentCreate event when that is done.
This commit is contained in:
parent
3d3b8f3427
commit
b69f6869bc
1 changed files with 7 additions and 0 deletions
|
@ -455,6 +455,11 @@ Blockly.ContextMenu.workspaceCommentOption = function(ws, e) {
|
|||
// Helper function to create and position a comment correctly based on the
|
||||
// location of the mouse event.
|
||||
var addWsComment = function() {
|
||||
// Disable events while this comment is getting created
|
||||
// so that we can fire a single create event for this comment
|
||||
// at the end (instead of CommentCreate followed by CommentMove,
|
||||
// which results in unexpected undo behavior).
|
||||
if (Blockly.Events.isEnabled()) Blockly.Events.disable();
|
||||
var comment = new Blockly.WorkspaceCommentSvg(
|
||||
ws, Blockly.Msg.WORKSPACE_COMMENT_DEFAULT_TEXT,
|
||||
Blockly.WorkspaceCommentSvg.DEFAULT_SIZE,
|
||||
|
@ -490,6 +495,8 @@ Blockly.ContextMenu.workspaceCommentOption = function(ws, e) {
|
|||
comment.render(false);
|
||||
comment.select();
|
||||
}
|
||||
Blockly.Events.enable();
|
||||
Blockly.WorkspaceComment.fireCreateEvent(comment);
|
||||
};
|
||||
|
||||
var wsCommentOption = {enabled: true};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue