@@ -582,6 +582,7 @@ class Canvas(_CanvasBase):
582
582
583
583
_client_ready_callbacks = Instance (CallbackDispatcher , ())
584
584
585
+ _mouse_wheel_callbacks = Instance (CallbackDispatcher , ())
585
586
_mouse_move_callbacks = Instance (CallbackDispatcher , ())
586
587
_mouse_down_callbacks = Instance (CallbackDispatcher , ())
587
588
_mouse_up_callbacks = Instance (CallbackDispatcher , ())
@@ -1507,6 +1508,10 @@ def on_mouse_out(self, callback, remove=False):
1507
1508
"""Register a callback that will be called on mouse out of the canvas."""
1508
1509
self ._mouse_out_callbacks .register_callback (callback , remove = remove )
1509
1510
1511
+ def on_mouse_wheel (self , callback , remove = False ):
1512
+ """Register a callback that will be called on mouse wheel movement."""
1513
+ self ._mouse_wheel_callbacks .register_callback (callback , remove = remove )
1514
+
1510
1515
def on_touch_start (self , callback , remove = False ):
1511
1516
"""Register a callback that will be called on touch start (new finger on the screen)."""
1512
1517
self ._touch_start_callbacks .register_callback (callback , remove = remove )
@@ -1551,6 +1556,8 @@ def _handle_frontend_event(self, _, content, buffers):
1551
1556
self ._mouse_up_callbacks (content ["x" ], content ["y" ])
1552
1557
if content .get ("event" , "" ) == "mouse_out" :
1553
1558
self ._mouse_out_callbacks (content ["x" ], content ["y" ])
1559
+ if content .get ("event" , "" ) == "mouse_wheel" :
1560
+ self ._mouse_wheel_callbacks (content ["x" ], content ["y" ])
1554
1561
1555
1562
if content .get ("event" , "" ) == "touch_start" :
1556
1563
self ._touch_start_callbacks (
@@ -1749,6 +1756,10 @@ def on_mouse_out(self, callback, remove=False):
1749
1756
"""Register a callback that will be called on mouse out of the canvas."""
1750
1757
self ._canvases [- 1 ].on_mouse_out (callback , remove = remove )
1751
1758
1759
+ def on_mouse_wheel (self , callback , remove = False ):
1760
+ """Register a callback that will be called on mouse wheel movement."""
1761
+ self ._canvases [- 1 ].on_mouse_wheel (callback , remove = remove )
1762
+
1752
1763
def on_touch_start (self , callback , remove = False ):
1753
1764
"""Register a callback that will be called on touch start (new finger on the screen)."""
1754
1765
self ._canvases [- 1 ].on_touch_start (callback , remove = remove )
0 commit comments