Skip to content
Merged
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
17 changes: 12 additions & 5 deletions js/src/mpl_widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({

mouse_event: function(name) {
var that = this;
var last_update = 0;
return function(event) {
var canvas_pos = utils.get_mouse_position(event);

Expand All @@ -391,12 +392,18 @@ var MPLCanvasView = widgets.DOMWidgetView.extend({
that.canvas_div.focus();
}

var x = canvas_pos.x * that.ratio;
var y = canvas_pos.y * that.ratio;
// Rate-limit the position text updates so that we don't overwhelm the
// system.
if (Date.now() > last_update + 40) {
last_update = Date.now();

that.send_message(name, {x: x, y: y, button: event.button,
step: event.step,
guiEvent: utils.get_simple_keys(event)});
var x = canvas_pos.x * that.ratio;
var y = canvas_pos.y * that.ratio;

that.send_message(name, {x: x, y: y, button: event.button,
step: event.step,
guiEvent: utils.get_simple_keys(event)});
}

/* This prevents the web browser from automatically changing to
* the text insertion cursor when the button is pressed. We want
Expand Down