MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / _keypress

Method _keypress

site-packages/matplotlib/widgets.py:774–809  ·  view source on GitHub ↗
(self, event)

Source from the content-addressed store, hash-verified

772 event.canvas.release_mouse(self.ax)
773
774 def _keypress(self, event):
775 if self.ignore(event):
776 return
777 if self.capturekeystrokes:
778 key = event.key
779
780 if(len(key) == 1):
781 self.text = (self.text[:self.cursor_index] + key +
782 self.text[self.cursor_index:])
783 self.cursor_index += 1
784 elif key == "right":
785 if self.cursor_index != len(self.text):
786 self.cursor_index += 1
787 elif key == "left":
788 if self.cursor_index != 0:
789 self.cursor_index -= 1
790 elif key == "home":
791 self.cursor_index = 0
792 elif key == "end":
793 self.cursor_index = len(self.text)
794 elif(key == "backspace"):
795 if self.cursor_index != 0:
796 self.text = (self.text[:self.cursor_index - 1] +
797 self.text[self.cursor_index:])
798 self.cursor_index -= 1
799 elif(key == "delete"):
800 if self.cursor_index != len(self.text):
801 self.text = (self.text[:self.cursor_index] +
802 self.text[self.cursor_index + 1:])
803
804 self.text_disp.remove()
805 self.text_disp = self._make_text_disp(self.text)
806 self._rendercursor()
807 self._notify_change_observers()
808 if key == "enter":
809 self._notify_submit_observers()
810
811 def set_val(self, val):
812 newval = str(val)

Callers

nothing calls this directly

Calls 6

_make_text_dispMethod · 0.95
_rendercursorMethod · 0.95
ignoreMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected