Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b68440f

Browse files
committed
Merge pull request #1093 from pelson/ability_to_disable_key_handling
Exposed the callback id for the default key press handler so that it can be easily diabled. Fixes #215.
2 parents e6818e7 + 6730eb4 commit b68440f

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

lib/matplotlib/backend_bases.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2413,7 +2413,17 @@ def __init__(self, canvas, num):
24132413
canvas.manager = self # store a pointer to parent
24142414
self.num = num
24152415

2416-
self.canvas.mpl_connect('key_press_event', self.key_press)
2416+
self.key_press_handler_id = self.canvas.mpl_connect('key_press_event',
2417+
self.key_press)
2418+
"""
2419+
The returned id from connecting the default key handler via :meth:`FigureCanvasBase.mpl_connnect`.
2420+
2421+
To disable default key press handling::
2422+
2423+
manager, canvas = figure.canvas.manager, figure.canvas
2424+
canvas.mpl_disconnect(manager.key_press_handler_id)
2425+
2426+
"""
24172427

24182428
def destroy(self):
24192429
pass

0 commit comments

Comments
 (0)