MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / on_key_press

Method on_key_press

lib/matplotlib/widgets.py:2539–2558  ·  view source on GitHub ↗

Key press event handler and validator for all selection widgets.

(self, event)

Source from the content-addressed store, hash-verified

2537
2538 @_call_with_reparented_event
2539 def on_key_press(self, event):
2540 """Key press event handler and validator for all selection widgets."""
2541 if self.active:
2542 key = event.key or ''
2543 key = key.replace('ctrl', 'control')
2544 if key == self._state_modifier_keys['clear']:
2545 self.clear()
2546 return
2547 for (state, modifier) in self._state_modifier_keys.items():
2548 if modifier in key.split('+'):
2549 # 'rotate' is changing _state on press and is not removed
2550 # from _state when releasing
2551 if state == 'rotate':
2552 if state in self._state:
2553 self._state.discard(state)
2554 else:
2555 self._state.add(state)
2556 else:
2557 self._state.add(state)
2558 self._on_key_press(event)
2559
2560 def _on_key_press(self, event):
2561 """Key press event handler - for widget-specific key press actions."""

Callers

nothing calls this directly

Calls 4

clearMethod · 0.95
_on_key_pressMethod · 0.95
discardMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected