Skip to content

Mousemove events not emitted after shift+mousedown with button 1 in Jupyter Lab #74

@edwardwkrohne

Description

@edwardwkrohne

I'm trying to allow the user to "draw" a line across a widget, and have the shift key have special meaning. I check mousemove events with button 1 depressed to do regular drawing, but for shift+draw, no events are emitted by ipyevents.

The following code has been modified from the example notebook.

from ipywidgets import Label, HTML, HBox, Image, VBox, Box, HBox
from ipyevents import Event 
from IPython.display import display

l = Label('Move the mouse across me!')
l.layout.border = '2px solid red'

h = HTML('Event info')
d = Event(source=l, watched_events=['mousemove'])

def handle_event(event):
    lines = ['{}: {}'.format(k, v) for k, v in event.items()]
    content = '<br>'.join(lines)
    h.value = content

d.on_dom_event(handle_event)
                            
display(l, h)

In Jupyter Lab,

  • Mouse moves with no buttons depressed are displayed.
  • Mouse moves with mouse button 1 depressed are displayed.
  • Mouse moves with the shift key depressed are displayed.
  • Mouse moves with shift and button 1 depressed, where shift went down before button 1, are not displayed. Releasing the shift key while leaving the mouse button down does not make mouse moves visible.
  • Mouse moves with shift and button 1 depressed, where the mouse button went down before shift are displayed.
  • Mouse moves with mouse button 2 depressed are displayed irrespective of the shift key.

In Jupyter Notebook, all events I just listed are displayed appropriately. Adding prevent_default_action=True had no effect.

!jupyter --version

produces

Selected Jupyter core packages...
IPython          : 8.3.0
ipykernel        : 6.13.0
ipywidgets       : 7.7.0
jupyter_client   : 7.3.1
jupyter_core     : 4.10.0
jupyter_server   : 1.17.0
jupyterlab       : 3.5.0b0
nbclient         : 0.6.3
nbconvert        : 6.5.0
nbformat         : 5.4.0
notebook         : 6.4.11
qtconsole        : 5.3.0
traitlets        : 5.2.1.post0

and

import ipyevents
ipyevents.__version__

produces

'2.0.1'

I upgraded from JupyterLab 3.4.0 to make this report; I got identical behavior in both versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions