Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/block_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,13 +538,14 @@ Blockly.Events.Move.prototype.run = function(forward) {
* @extends {Blockly.Events.BlockBase}
* @constructor
*/
Blockly.Events.HintClick = function(hint) {
Blockly.Events.HintClick = function(hint, interactionType) {
if (!hint) {
return; // Blank event to be populated by fromJson.
}
Blockly.Events.HintClick.superClass_.constructor.call(this);
this.hintId = hint.getText();
this.recordUndo = false;
this.interactionType = interactionType;
};
goog.inherits(Blockly.Events.HintClick, Blockly.Events.Abstract);

Expand Down
9 changes: 8 additions & 1 deletion core/hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ Blockly.Hint.prototype.setVisible = function(visible) {
content, this.block_.svgPath_, this.iconXY_, null, null);
// specific for hint
this.bubble_.registerContextMenuCallback(this.showContextMenu_.bind(this));
this.bubble_.registerMouseOverCallback(this.showCodeHint_.bind(this));

if (this.block_.RTL) {
// Right-align the paragraph.
Expand Down Expand Up @@ -181,6 +182,12 @@ Blockly.Hint.prototype.showContextMenu_ = function(e) {
Blockly.ContextMenu.show(e, menuOptions, this.block_.RTL);
};

Blockly.Hint.prototype.showCodeHint_ = function(e) {
var event = new Blockly.Events.HintClick(this,"mouseover");
event.workspaceId = this.block_.workspace.id;
Blockly.Events.fire(event);
}

/**
* Make a context menu option for action resolving the hint
* @param {!Blockly.Hint} hint The hint where the
Expand All @@ -195,7 +202,7 @@ Blockly.Hint.hintImproveOption = function(hint) {
enabled: true,
callback: function() {
console.log("Hint callback to improve get invoked");
var event = new Blockly.Events.HintClick(hint);
var event = new Blockly.Events.HintClick(hint, "improve_option_click");
event.workspaceId = wsId;
Blockly.Events.fire(event);
}
Expand Down
11 changes: 11 additions & 0 deletions core/hint_bubble.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ Blockly.HintBubble = function(workspace, content, shape, anchorXY,
this.rendered_ = true;

if (!workspace.options.readOnly) {
Blockly.bindEvent_(this.content_, 'mouseover', this, this.bubbleMouseOver_);
Blockly.bindEventWithChecks_(
this.content_, 'mousedown', this, this.bubbleMouseDown_);
}
Expand All @@ -87,6 +88,10 @@ Blockly.HintBubble.prototype.registerContextMenuCallback = function(callback) {
this.contextMenuCallback_ = callback;
};

Blockly.HintBubble.prototype.registerMouseOverCallback = function(callback) {
this.mouseoverCallback_ = callback;
};

/**
* Width of the border around the bubble.
*/
Expand Down Expand Up @@ -281,6 +286,12 @@ Blockly.HintBubble.prototype.showContextMenu_ = function(_e) {
}
};

Blockly.HintBubble.prototype.bubbleMouseOver_ = function(_e){
if(this.mouseoverCallback_){
this.mouseoverCallback_(_e);
}
}

/**
* Get whether this bubble is deletable or not.
* @return {boolean} True if deletable.
Expand Down