KMOCRBox.m 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // KMBox.m
  3. // SignFlow
  4. //
  5. // Created by wanjun on 2020/10/21.
  6. //
  7. #import "KMOCRBox.h"
  8. @implementation KMOCRBox
  9. - (void)viewDidMoveToWindow {
  10. [super viewDidMoveToWindow];
  11. if ([self window] != nil) {
  12. [self addTrackingRect:[self bounds]
  13. owner:self
  14. userData:NULL
  15. assumeInside:NO];
  16. }
  17. }
  18. - (void)setFrameSize:(NSSize)newSize {
  19. [super setFrameSize:newSize];
  20. [self addTrackingRect:NSMakeRect(0, 0, newSize.width, newSize.height)
  21. owner:self
  22. userData:NULL
  23. assumeInside:NO];
  24. }
  25. - (void)mouseEntered:(NSEvent *)event {
  26. if (self.mouseMoveCallback) {
  27. self.mouseMoveCallback(YES, self);
  28. }
  29. }
  30. - (void)mouseExited:(NSEvent *)event {
  31. if (self.mouseMoveCallback) {
  32. self.mouseMoveCallback(NO, self);
  33. }
  34. }
  35. - (void)mouseDown:(NSEvent *)event {
  36. [super mouseDown:event];
  37. if (self.mouseDownCallback) {
  38. self.mouseDownCallback(YES, self);
  39. }
  40. }
  41. - (void)mouseUp:(NSEvent *)event {
  42. [super mouseUp:event];
  43. if (self.mouseDownCallback) {
  44. self.mouseDownCallback(NO, self);
  45. }
  46. }
  47. @end