Browse Source

improve docstring for `ui.interative_image` (#1712)

Falko Schindler 1 year ago
parent
commit
cbba12ed03
1 changed files with 8 additions and 1 deletions
  1. 8 1
      nicegui/elements/interactive_image.py

+ 8 - 1
nicegui/elements/interactive_image.py

@@ -37,13 +37,20 @@ class InteractiveImage(SourceElement, ContentElement, component='interactive_ima
         Thereby repeatedly updating the image source will automatically adapt to the available bandwidth.
         See `OpenCV Webcam <https://github.com/zauberzeug/nicegui/tree/main/examples/opencv_webcam/main.py>`_ for an example.
 
+        The mouse event handler is called with mouse event arguments containing
+
+        - `type` (the name of the JavaScript event),
+        - `image_x` and `image_y` (image coordinates in pixels),
+        - `button` and `buttons` (mouse button numbers from the JavaScript event), as well as
+        - `alt`, `ctrl`, `meta`, and `shift` (modifier keys from the JavaScript event).
+
         You can also pass a tuple of width and height instead of an image source.
         This will create an empty image with the given size.
 
         :param source: the source of the image; can be an URL, local file path, a base64 string or just an image size
         :param content: SVG content which should be overlaid; viewport has the same dimensions as the image
         :param size: size of the image (width, height) in pixels; only used if `source` is not set
-        :param on_mouse: callback for mouse events (yields `type`, `image_x` and `image_y`)
+        :param on_mouse: callback for mouse events (contains image coordinates `image_x` and `image_y` in pixels)
         :param events: list of JavaScript events to subscribe to (default: `['click']`)
         :param cross: whether to show crosshairs (default: `False`)
         """