From fa6b6fdf9e47da31f802b0efc87fe2d16418d49d Mon Sep 17 00:00:00 2001 From: kushalkolar Date: Mon, 27 Nov 2023 03:06:24 -0500 Subject: [PATCH] allow setting the cursor --- js/lib/widget.js | 7 ++++++- jupyter_rfb/widget.py | 3 +++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/js/lib/widget.js b/js/lib/widget.js index de09eff..734e5d3 100644 --- a/js/lib/widget.js +++ b/js/lib/widget.js @@ -35,7 +35,8 @@ export class RemoteFrameBufferModel extends DOMWidgetModel { css_width: '500px', css_height: '300px', resizable: true, - has_visible_views: false + has_visible_views: false, + cursor: 'default' }; } initialize() { @@ -204,6 +205,10 @@ export class RemoteFrameBufferView extends DOMWidgetView { this.el.appendChild(this.img); this.model.collect_view_img_elements(); + // Cursor + this.el.style.cursor = this.model.get('cursor'); + this.model.on('change:cursor', function () { this.el.style.cursor = this.model.get('cursor'); }, this); + // Set of throttler functions to send events at a friendly pace this._throttlers = {}; diff --git a/jupyter_rfb/widget.py b/jupyter_rfb/widget.py index b3433a4..ac77a41 100644 --- a/jupyter_rfb/widget.py +++ b/jupyter_rfb/widget.py @@ -47,6 +47,8 @@ class RemoteFrameBuffer(ipywidgets.DOMWidget): * *max_buffered_frames*: the number of frames that is allowed to be "in-flight", i.e. sent, but not yet confirmed by the client. Default 2. Higher values may result in a higher FPS at the cost of introducing lag. + * *cursor*: the cursor style, ex: "crosshair", "grab". Valid cursors: + https://developer.mozilla.org/en-US/docs/Web/CSS/cursor#keyword """ @@ -75,6 +77,7 @@ class RemoteFrameBuffer(ipywidgets.DOMWidget): css_width = Unicode("500px").tag(sync=True) css_height = Unicode("300px").tag(sync=True) resizable = Bool(True).tag(sync=True) + cursor = Unicode("default").tag(sync=True) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs)