plexpy/lib/rumps/text_field.py
dependabot[bot] 79cf61c53e
Bump rumps from 0.3.0 to 0.4.0 (#1896)
* Bump rumps from 0.3.0 to 0.4.0

Bumps [rumps](https://github.com/jaredks/rumps) from 0.3.0 to 0.4.0.
- [Release notes](https://github.com/jaredks/rumps/releases)
- [Changelog](https://github.com/jaredks/rumps/blob/master/CHANGES.rst)
- [Commits](https://github.com/jaredks/rumps/commits)

---
updated-dependencies:
- dependency-name: rumps
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update rumps==0.4.0

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>

[skip ci]
2022-11-14 11:27:16 -08:00

33 lines
1.4 KiB
Python

from AppKit import NSApplication, NSTextField, NSSecureTextField, NSKeyDown, NSCommandKeyMask
class Editing(NSTextField):
"""NSTextField with cut, copy, paste, undo and selectAll"""
def performKeyEquivalent_(self, event):
return _perform_key_equivalent(self, event)
class SecureEditing(NSSecureTextField):
"""NSSecureTextField with cut, copy, paste, undo and selectAll"""
def performKeyEquivalent_(self, event):
return _perform_key_equivalent(self, event)
def _perform_key_equivalent(self, event):
if event.type() == NSKeyDown and event.modifierFlags() & NSCommandKeyMask:
if event.charactersIgnoringModifiers() == "x":
NSApplication.sharedApplication().sendAction_to_from_("cut:", None, self)
return True
elif event.charactersIgnoringModifiers() == "c":
NSApplication.sharedApplication().sendAction_to_from_("copy:", None, self)
return True
elif event.charactersIgnoringModifiers() == "v":
NSApplication.sharedApplication().sendAction_to_from_("paste:", None, self)
return True
elif event.charactersIgnoringModifiers() == "z":
NSApplication.sharedApplication().sendAction_to_from_("undo:", None, self)
return True
elif event.charactersIgnoringModifiers() == "a":
NSApplication.sharedApplication().sendAction_to_from_("selectAll:", None, self)
return True