diff --git a/js/lib/widget.js b/js/lib/widget.js index 307cd65..9f3d5ba 100644 --- a/js/lib/widget.js +++ b/js/lib/widget.js @@ -264,6 +264,22 @@ export class RemoteFrameBufferView extends DOMWidgetView { let event = create_pointer_event(that.img, e, that._pointers, 'pointer_move'); that.send_throttled(event, 20); }); + this.img.addEventListener('pointerenter', function (e) { + // If this pointer is not down, but other pointers are, don't emit an event. + if (that._pointers[e.pointerId] === undefined) { + if (Object.keys(that._pointers).length > 0) { return; } + } + let event = create_pointer_event(that.img, e, {[e.pointerId]: e}, 'pointer_enter'); + that.send(event); + }); + this.img.addEventListener('pointerleave', function (e) { + // If this pointer is not down, but other pointers are, don't emit an event. + if (that._pointers[e.pointerId] === undefined) { + if (Object.keys(that._pointers).length > 0) { return; } + } + let event = create_pointer_event(that.img, e, {[e.pointerId]: e}, 'pointer_leave'); + that.send(event); + }); // Click events are not pointer events. Not sure if we need click events. It seems to make // less sense, because the img is just a single element. Only double-click for now. diff --git a/jupyter_rfb/events.py b/jupyter_rfb/events.py index 79357b1..7af74ba 100644 --- a/jupyter_rfb/events.py +++ b/jupyter_rfb/events.py @@ -40,6 +40,14 @@ This event has the same keys as the pointer down event. This event is throttled. +* **pointer_enter**: emitted when the user moves a pointer into the + boundary of the widget. + This event has no additional keys. + +* **pointer_leave**: emitted when the user moves a pointer out of the + boundary of the widget. + This event has no additional keys. + * **double_click**: emitted on a double-click. This event looks like a pointer event, but without the touches.