NSTextField+Layer.swift 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // NSTextField+Layer.swift
  3. // PDF Master
  4. //
  5. // Created by lizhe on 2023/2/16.
  6. //
  7. import Foundation
  8. extension NSTextField {
  9. open override var focusRingType: NSFocusRingType {
  10. get {.none}
  11. set {}
  12. }
  13. // - (void)mouseDown:(NSEvent *)event {
  14. // [super mouseDown:event];
  15. //
  16. // if ([self currentEditor]) {
  17. // if ([self.delegate respondsToSelector:@selector(customTextFieldWillBeginEditing:)])
  18. // [(id<CustomTextFieldDelegate>)self.delegate customTextFieldWillBeginEditing:self];
  19. // }
  20. // }
  21. //
  22. // - (BOOL)becomeFirstResponder {
  23. // BOOL success = [super becomeFirstResponder];
  24. // if(success) {
  25. // NSTextView * textView = (NSTextView *)[self currentEditor];
  26. //
  27. // if([textView respondsToSelector:@selector(setInsertionPointColor:)]) {
  28. //
  29. // [textView setInsertionPointColor:[NSColor whiteColor]];
  30. //
  31. // }
  32. //
  33. // }
  34. //
  35. // return success;
  36. // }
  37. //
  38. // - (BOOL)performKeyEquivalent:(NSEvent *)event {
  39. // NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard];
  40. // if (([event modifierFlags] & NSEventModifierFlagDeviceIndependentFlagsMask) == NSEventModifierFlagCommand) {
  41. // // The command key is the ONLY modifier key being pressed.
  42. // if ([[event charactersIgnoringModifiers] isEqualToString:@"x"] &&
  43. // [[[self window] firstResponder] respondsToSelector:@selector(cut:)]) {
  44. // return [NSApp sendAction:@selector(cut:) to:[[self window] firstResponder] from:self];
  45. // } else if ([[event charactersIgnoringModifiers] isEqualToString:@"c"] &&
  46. // [[[self window] firstResponder] respondsToSelector:@selector(copy:)]) {
  47. // return [NSApp sendAction:@selector(copy:) to:[[self window] firstResponder] from:self];
  48. // } else if ([[event charactersIgnoringModifiers] isEqualToString:@"v"] &&
  49. // [[[self window] firstResponder] respondsToSelector:@selector(paste:)] &&
  50. // [pasteBoard stringForType:NSPasteboardTypeString] != nil) {
  51. // return [NSApp sendAction:@selector(paste:) to:[[self window] firstResponder] from:self];
  52. // } else if ([[event charactersIgnoringModifiers] isEqualToString:@"a"] &&
  53. // [[[self window] firstResponder] respondsToSelector:@selector(selectAll:)]) {
  54. // return [NSApp sendAction:@selector(selectAll:) to:[[self window] firstResponder] from:self];
  55. // }
  56. // }
  57. //
  58. // return [super performKeyEquivalent:event];
  59. // }
  60. }