2015-07-17 00:40:46 +00:00
|
|
|
//
|
2020-08-04 22:22:14 +00:00
|
|
|
// CSScanTargetView
|
2015-07-26 19:25:11 +00:00
|
|
|
// CLK
|
2015-07-17 00:40:46 +00:00
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 16/07/2015.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2015 Thomas Harte. All rights reserved.
|
2015-07-17 00:40:46 +00:00
|
|
|
//
|
|
|
|
|
2020-08-04 22:22:14 +00:00
|
|
|
#import "CSScanTargetView.h"
|
2019-09-22 17:15:35 +00:00
|
|
|
#import "CSApplication.h"
|
2020-08-04 23:44:56 +00:00
|
|
|
#import "CSScanTarget.h"
|
2015-07-17 00:40:46 +00:00
|
|
|
@import CoreVideo;
|
2015-09-25 01:23:16 +00:00
|
|
|
@import GLKit;
|
2015-07-17 00:40:46 +00:00
|
|
|
|
2020-03-23 01:11:04 +00:00
|
|
|
#include <stdatomic.h>
|
|
|
|
|
2021-07-12 23:12:04 +00:00
|
|
|
static const NSTimeInterval standardMouseHideInterval = 3.0;
|
|
|
|
static const NSTimeInterval quickMouseHideInterval = 0.1;
|
|
|
|
|
2020-08-04 22:22:14 +00:00
|
|
|
@interface CSScanTargetView () <NSDraggingDestination, CSApplicationEventDelegate>
|
2017-08-17 14:48:29 +00:00
|
|
|
@end
|
|
|
|
|
2020-08-04 22:22:14 +00:00
|
|
|
@implementation CSScanTargetView {
|
2016-02-05 03:28:50 +00:00
|
|
|
CVDisplayLinkRef _displayLink;
|
2020-03-21 21:01:57 +00:00
|
|
|
NSNumber *_currentScreenNumber;
|
2019-03-07 02:49:50 +00:00
|
|
|
|
|
|
|
NSTrackingArea *_mouseTrackingArea;
|
|
|
|
NSTimer *_mouseHideTimer;
|
2019-06-11 20:30:53 +00:00
|
|
|
BOOL _mouseIsCaptured;
|
2020-03-21 03:00:16 +00:00
|
|
|
|
2020-03-23 01:11:04 +00:00
|
|
|
atomic_int _isDrawingFlag;
|
2020-03-21 03:00:16 +00:00
|
|
|
BOOL _isInvalid;
|
2020-08-04 23:44:56 +00:00
|
|
|
|
|
|
|
CSScanTarget *_scanTarget;
|
2015-07-17 00:40:46 +00:00
|
|
|
}
|
|
|
|
|
2020-01-27 04:23:33 +00:00
|
|
|
- (void)setupDisplayLink {
|
2020-03-21 03:00:16 +00:00
|
|
|
// Kill the existing link if there is one.
|
2020-01-27 04:23:33 +00:00
|
|
|
if(_displayLink) {
|
2020-03-21 03:00:16 +00:00
|
|
|
[self stopDisplayLink];
|
2020-01-27 04:23:33 +00:00
|
|
|
CVDisplayLinkRelease(_displayLink);
|
|
|
|
}
|
|
|
|
|
2020-03-21 03:00:16 +00:00
|
|
|
// Create a display link for the display the window is currently on.
|
2020-01-27 04:23:33 +00:00
|
|
|
NSNumber *const screenNumber = self.window.screen.deviceDescription[@"NSScreenNumber"];
|
2020-03-21 21:01:57 +00:00
|
|
|
_currentScreenNumber = screenNumber;
|
2020-01-27 04:23:33 +00:00
|
|
|
CVDisplayLinkCreateWithCGDisplay(screenNumber.unsignedIntValue, &_displayLink);
|
2016-04-21 02:35:46 +00:00
|
|
|
|
2020-03-21 03:00:16 +00:00
|
|
|
// Set the renderer output callback function.
|
2016-02-05 03:28:50 +00:00
|
|
|
CVDisplayLinkSetOutputCallback(_displayLink, DisplayLinkCallback, (__bridge void * __nullable)(self));
|
2016-03-04 03:12:31 +00:00
|
|
|
|
2020-03-21 03:00:16 +00:00
|
|
|
// Activate the display link.
|
2016-02-05 03:28:50 +00:00
|
|
|
CVDisplayLinkStart(_displayLink);
|
2015-07-17 01:16:21 +00:00
|
|
|
}
|
2015-07-17 00:40:46 +00:00
|
|
|
|
2020-05-30 05:06:43 +00:00
|
|
|
static CVReturn DisplayLinkCallback(__unused CVDisplayLinkRef displayLink, const CVTimeStamp *now, const CVTimeStamp *outputTime, __unused CVOptionFlags flagsIn, __unused CVOptionFlags *flagsOut, void *displayLinkContext) {
|
2020-08-04 22:22:14 +00:00
|
|
|
CSScanTargetView *const view = (__bridge CSScanTargetView *)displayLinkContext;
|
2020-01-27 04:23:33 +00:00
|
|
|
|
2020-03-21 03:00:16 +00:00
|
|
|
// Schedule an opportunity to check that the display link is still linked to the correct display.
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[view checkDisplayLink];
|
|
|
|
});
|
|
|
|
|
|
|
|
// Ensure _isDrawingFlag has value 1 when drawing, 0 otherwise.
|
2020-03-23 01:11:04 +00:00
|
|
|
atomic_store(&view->_isDrawingFlag, 1);
|
2020-03-21 03:00:16 +00:00
|
|
|
|
2020-09-14 02:11:51 +00:00
|
|
|
[view.displayLinkDelegate scanTargetViewDisplayLinkDidFire:view now:now outputTime:outputTime];
|
2020-01-27 04:23:33 +00:00
|
|
|
/*
|
|
|
|
Do not touch the display link from after this call; there's a bit of a race condition with setupDisplayLink.
|
|
|
|
Specifically: Apple provides CVDisplayLinkStop but a call to that merely prevents future calls to the callback,
|
|
|
|
it doesn't wait for completion of any current calls. So I've set up a usleep for one callback's duration,
|
|
|
|
so code in here gets one callback's duration to access the display link.
|
|
|
|
|
|
|
|
In practice, it should do so only upon entry, and before calling into the view. The view promises not to
|
|
|
|
access the display link itself as part of -drawAtTime:frequency:.
|
|
|
|
*/
|
|
|
|
|
2020-03-23 01:11:04 +00:00
|
|
|
atomic_store(&view->_isDrawingFlag, 0);
|
2020-03-21 03:00:16 +00:00
|
|
|
|
2015-07-17 01:16:21 +00:00
|
|
|
return kCVReturnSuccess;
|
|
|
|
}
|
2015-07-28 01:15:10 +00:00
|
|
|
|
2020-02-04 02:58:29 +00:00
|
|
|
- (void)checkDisplayLink {
|
2020-03-21 03:00:16 +00:00
|
|
|
// Don't do anything if this view has already been invalidated.
|
|
|
|
if(_isInvalid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-01-27 04:23:33 +00:00
|
|
|
// Test now whether the screen this view is on has changed since last time it was checked.
|
|
|
|
// There's likely a callback available for this, on NSWindow if nowhere else, or an NSNotification,
|
|
|
|
// but since this method is going to be called repeatedly anyway, and the test is cheap, polling
|
|
|
|
// feels fine.
|
2020-03-21 21:01:57 +00:00
|
|
|
NSNumber *const screenNumber = self.window.screen.deviceDescription[@"NSScreenNumber"];
|
|
|
|
if(![_currentScreenNumber isEqual:screenNumber]) {
|
2020-01-27 04:23:33 +00:00
|
|
|
// Also switch display links, to make sure synchronisation is with the display
|
|
|
|
// the window is actually on, and at its rate.
|
|
|
|
[self setupDisplayLink];
|
2020-01-26 23:04:25 +00:00
|
|
|
}
|
2020-02-04 02:58:29 +00:00
|
|
|
}
|
2020-01-26 23:04:25 +00:00
|
|
|
|
2019-03-07 02:54:21 +00:00
|
|
|
- (void)invalidate {
|
2020-03-21 03:00:16 +00:00
|
|
|
_isInvalid = YES;
|
|
|
|
[self stopDisplayLink];
|
|
|
|
}
|
|
|
|
|
2022-07-12 13:56:13 +00:00
|
|
|
- (double)refreshPeriod {
|
|
|
|
return CVDisplayLinkGetActualOutputVideoRefreshPeriod(_displayLink);
|
|
|
|
}
|
|
|
|
|
2020-03-21 03:00:16 +00:00
|
|
|
- (void)stopDisplayLink {
|
2022-07-12 13:56:13 +00:00
|
|
|
const double duration = [self refreshPeriod];
|
2016-02-05 03:28:50 +00:00
|
|
|
CVDisplayLinkStop(_displayLink);
|
2020-03-12 02:09:36 +00:00
|
|
|
|
2020-03-21 03:00:16 +00:00
|
|
|
// This is a workaround; CVDisplayLinkStop does not wait for any existing call to the
|
|
|
|
// display-link callback to stop. Furthermore there's a race condition between a callback
|
|
|
|
// and any ability by me to set state.
|
|
|
|
//
|
|
|
|
// So: wait for a whole display link tick to avoid the second race condition. Then spin
|
|
|
|
// on an atomic flag.
|
2020-03-12 02:09:36 +00:00
|
|
|
usleep((useconds_t)ceil(duration * 1000000.0));
|
2020-03-21 03:00:16 +00:00
|
|
|
|
|
|
|
// Spin until _isDrawingFlag is 0 (and leave it as 0).
|
2020-03-23 01:11:04 +00:00
|
|
|
int expected_value = 0;
|
|
|
|
while(!atomic_compare_exchange_weak(&_isDrawingFlag, &expected_value, 0)) {
|
|
|
|
expected_value = 0;
|
|
|
|
}
|
2015-07-28 01:15:10 +00:00
|
|
|
}
|
|
|
|
|
2019-03-07 02:54:21 +00:00
|
|
|
- (void)dealloc {
|
2020-01-27 04:23:33 +00:00
|
|
|
// Stop and release the display link
|
|
|
|
CVDisplayLinkStop(_displayLink);
|
2016-02-05 03:28:50 +00:00
|
|
|
CVDisplayLinkRelease(_displayLink);
|
2015-07-17 00:40:46 +00:00
|
|
|
}
|
|
|
|
|
2020-08-09 02:49:02 +00:00
|
|
|
- (CSScanTarget *)scanTarget {
|
|
|
|
return _scanTarget;
|
|
|
|
}
|
|
|
|
|
2021-05-01 01:37:41 +00:00
|
|
|
- (void)willChangeScanTargetOwner {
|
|
|
|
[_scanTarget willChangeOwner];
|
|
|
|
}
|
|
|
|
|
2020-08-16 01:24:10 +00:00
|
|
|
- (void)updateBacking {
|
|
|
|
[_scanTarget updateFrameBuffer];
|
|
|
|
}
|
2015-07-24 02:51:53 +00:00
|
|
|
|
2019-03-07 02:54:21 +00:00
|
|
|
- (void)awakeFromNib {
|
2024-01-17 07:28:31 +00:00
|
|
|
self.device = MTLCreateSystemDefaultDevice();
|
2020-08-04 23:44:56 +00:00
|
|
|
|
2020-09-14 02:11:51 +00:00
|
|
|
// Configure for explicit drawing.
|
|
|
|
self.paused = YES;
|
|
|
|
self.enableSetNeedsDisplay = NO;
|
|
|
|
|
2020-08-04 23:44:56 +00:00
|
|
|
// Create the scan target.
|
|
|
|
_scanTarget = [[CSScanTarget alloc] initWithView:self];
|
|
|
|
self.delegate = _scanTarget;
|
2017-08-17 14:48:29 +00:00
|
|
|
|
|
|
|
// Register to receive dragged and dropped file URLs.
|
|
|
|
[self registerForDraggedTypes:@[(__bridge NSString *)kUTTypeFileURL]];
|
2020-09-14 02:11:51 +00:00
|
|
|
|
|
|
|
// Setup the [initial] display link.
|
|
|
|
[self setupDisplayLink];
|
2015-07-24 02:51:53 +00:00
|
|
|
}
|
|
|
|
|
2015-08-19 00:33:24 +00:00
|
|
|
#pragma mark - NSResponder
|
|
|
|
|
2019-03-07 02:54:21 +00:00
|
|
|
- (BOOL)acceptsFirstResponder {
|
2015-08-19 00:33:24 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2019-09-25 02:31:20 +00:00
|
|
|
- (void)keyDown:(NSEvent *)event {
|
|
|
|
[self.responderDelegate keyDown:event];
|
2019-09-22 17:15:35 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 02:31:20 +00:00
|
|
|
- (void)keyUp:(NSEvent *)event {
|
|
|
|
[self.responderDelegate keyUp:event];
|
2015-08-19 00:33:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-25 02:31:20 +00:00
|
|
|
- (void)flagsChanged:(NSEvent *)event {
|
|
|
|
// Release the mouse upon a control + command.
|
|
|
|
if(_mouseIsCaptured &&
|
|
|
|
event.modifierFlags & NSEventModifierFlagControl &&
|
|
|
|
event.modifierFlags & NSEventModifierFlagCommand) {
|
|
|
|
[self releaseMouse];
|
|
|
|
}
|
2015-08-19 00:33:24 +00:00
|
|
|
|
2019-09-25 02:31:20 +00:00
|
|
|
[self.responderDelegate flagsChanged:event];
|
2019-09-22 17:15:35 +00:00
|
|
|
}
|
2019-06-11 20:30:53 +00:00
|
|
|
|
2019-09-25 02:31:20 +00:00
|
|
|
- (BOOL)application:(nonnull CSApplication *)application shouldSendEvent:(nonnull NSEvent *)event {
|
|
|
|
switch(event.type) {
|
|
|
|
default: return YES;
|
|
|
|
case NSEventTypeKeyUp: [self keyUp:event]; return NO;
|
|
|
|
case NSEventTypeKeyDown: [self keyDown:event]; return NO;
|
|
|
|
case NSEventTypeFlagsChanged: [self flagsChanged:event]; return NO;
|
|
|
|
}
|
2015-08-19 00:33:24 +00:00
|
|
|
}
|
|
|
|
|
2019-03-07 02:54:21 +00:00
|
|
|
- (void)paste:(id)sender {
|
2018-05-13 15:12:03 +00:00
|
|
|
[self.responderDelegate paste:sender];
|
|
|
|
}
|
|
|
|
|
2020-09-14 02:30:17 +00:00
|
|
|
- (NSBitmapImageRep *)imageRepresentation {
|
|
|
|
return self.scanTarget.imageRepresentation;
|
|
|
|
}
|
|
|
|
|
2017-08-17 14:48:29 +00:00
|
|
|
#pragma mark - NSDraggingDestination
|
|
|
|
|
2019-03-07 02:54:21 +00:00
|
|
|
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender {
|
|
|
|
for(NSPasteboardItem *item in [[sender draggingPasteboard] pasteboardItems]) {
|
2017-08-17 14:48:29 +00:00
|
|
|
NSURL *URL = [NSURL URLWithString:[item stringForType:(__bridge NSString *)kUTTypeFileURL]];
|
2020-09-14 02:11:51 +00:00
|
|
|
[self.responderDelegate scanTargetView:self didReceiveFileAtURL:URL];
|
2017-08-17 14:48:29 +00:00
|
|
|
}
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
2019-03-07 02:54:21 +00:00
|
|
|
- (NSDragOperation)draggingEntered:(id < NSDraggingInfo >)sender {
|
2017-08-17 14:48:29 +00:00
|
|
|
return NSDragOperationLink;
|
|
|
|
}
|
|
|
|
|
2019-03-07 02:49:50 +00:00
|
|
|
#pragma mark - Mouse hiding
|
|
|
|
|
2019-06-11 20:30:53 +00:00
|
|
|
- (void)setShouldCaptureMouse:(BOOL)shouldCaptureMouse {
|
|
|
|
_shouldCaptureMouse = shouldCaptureMouse;
|
|
|
|
}
|
|
|
|
|
2019-03-07 02:49:50 +00:00
|
|
|
- (void)updateTrackingAreas {
|
|
|
|
[super updateTrackingAreas];
|
|
|
|
|
|
|
|
if(_mouseTrackingArea) {
|
|
|
|
[self removeTrackingArea:_mouseTrackingArea];
|
|
|
|
}
|
|
|
|
_mouseTrackingArea =
|
|
|
|
[[NSTrackingArea alloc]
|
|
|
|
initWithRect:self.bounds
|
|
|
|
options:NSTrackingMouseEnteredAndExited | NSTrackingMouseMoved | NSTrackingActiveWhenFirstResponder
|
|
|
|
owner:self
|
|
|
|
userInfo:nil];
|
|
|
|
[self addTrackingArea:_mouseTrackingArea];
|
|
|
|
}
|
|
|
|
|
2021-07-12 23:12:04 +00:00
|
|
|
- (void)scheduleMouseHideAfter:(NSTimeInterval)interval {
|
2021-07-16 21:21:25 +00:00
|
|
|
[_mouseHideTimer invalidate];
|
2019-06-11 20:30:53 +00:00
|
|
|
|
2021-07-16 21:21:25 +00:00
|
|
|
_mouseHideTimer = [NSTimer scheduledTimerWithTimeInterval:interval repeats:NO block:^(__unused NSTimer * _Nonnull timer) {
|
|
|
|
// Don't actually hide the mouse if this is a mouse-capture machine; that makes
|
|
|
|
// it fairly confusing as to current application state.
|
|
|
|
if(!self.shouldCaptureMouse) {
|
2019-06-11 20:30:53 +00:00
|
|
|
[NSCursor setHiddenUntilMouseMoves:YES];
|
2021-07-16 21:21:25 +00:00
|
|
|
}
|
|
|
|
[self.responderDelegate scanTargetViewWouldHideOSMouseCursor:self];
|
|
|
|
}];
|
2019-03-07 02:49:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)mouseEntered:(NSEvent *)event {
|
|
|
|
[super mouseEntered:event];
|
2021-07-12 23:12:04 +00:00
|
|
|
|
|
|
|
[self.responderDelegate scanTargetViewDidShowOSMouseCursor:self];
|
|
|
|
[self scheduleMouseHideAfter:standardMouseHideInterval];
|
2019-03-07 02:49:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)mouseExited:(NSEvent *)event {
|
|
|
|
[super mouseExited:event];
|
2021-07-12 23:12:04 +00:00
|
|
|
|
|
|
|
// Schedule a really short mouse-hiding interval.
|
|
|
|
[self scheduleMouseHideAfter:quickMouseHideInterval];
|
2019-03-07 02:49:50 +00:00
|
|
|
}
|
|
|
|
|
2019-06-11 20:30:53 +00:00
|
|
|
- (void)releaseMouse {
|
2019-06-13 17:39:35 +00:00
|
|
|
if(_mouseIsCaptured) {
|
|
|
|
_mouseIsCaptured = NO;
|
|
|
|
CGAssociateMouseAndMouseCursorPosition(true);
|
|
|
|
[NSCursor unhide];
|
2020-09-14 02:11:51 +00:00
|
|
|
[self.responderDelegate scanTargetViewDidReleaseMouse:self];
|
|
|
|
[self.responderDelegate scanTargetViewDidShowOSMouseCursor:self];
|
2019-09-25 02:31:20 +00:00
|
|
|
((CSApplication *)[NSApplication sharedApplication]).eventDelegate = nil;
|
2019-06-13 17:39:35 +00:00
|
|
|
}
|
2019-06-11 20:30:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Mouse motion
|
|
|
|
|
|
|
|
- (void)applyMouseMotion:(NSEvent *)event {
|
2021-07-16 21:21:25 +00:00
|
|
|
if(!_mouseIsCaptured) {
|
2019-06-11 20:30:53 +00:00
|
|
|
// Mouse capture is off, so don't play games with the cursor, just schedule it to
|
|
|
|
// hide in the near future.
|
2021-07-12 23:12:04 +00:00
|
|
|
[self scheduleMouseHideAfter:standardMouseHideInterval];
|
2020-09-14 02:11:51 +00:00
|
|
|
[self.responderDelegate scanTargetViewDidShowOSMouseCursor:self];
|
2019-06-11 20:30:53 +00:00
|
|
|
} else {
|
2021-07-16 21:21:25 +00:00
|
|
|
// Mouse capture is on, so move the cursor back to the middle of the window, and
|
|
|
|
// forward the deltas to the listener.
|
|
|
|
//
|
|
|
|
// TODO: should I really need to invert the y coordinate myself? It suggests I
|
|
|
|
// might have an error in mapping here.
|
|
|
|
const NSPoint windowCentre = [self convertPoint:CGPointMake(self.bounds.size.width * 0.5, self.bounds.size.height * 0.5) toView:nil];
|
|
|
|
const NSPoint screenCentre = [self.window convertPointToScreen:windowCentre];
|
|
|
|
const CGRect screenFrame = self.window.screen.frame;
|
|
|
|
CGWarpMouseCursorPosition(NSMakePoint(
|
|
|
|
screenFrame.origin.x + screenCentre.x,
|
|
|
|
screenFrame.origin.y + screenFrame.size.height - screenCentre.y
|
|
|
|
));
|
|
|
|
|
|
|
|
[self.responderDelegate mouseMoved:event];
|
2019-06-11 20:30:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)mouseDragged:(NSEvent *)event {
|
|
|
|
[self applyMouseMotion:event];
|
|
|
|
[super mouseDragged:event];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)rightMouseDragged:(NSEvent *)event {
|
|
|
|
[self applyMouseMotion:event];
|
|
|
|
[super rightMouseDragged:event];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)otherMouseDragged:(NSEvent *)event {
|
|
|
|
[self applyMouseMotion:event];
|
|
|
|
[super otherMouseDragged:event];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)mouseMoved:(NSEvent *)event {
|
|
|
|
[self applyMouseMotion:event];
|
|
|
|
[super mouseMoved:event];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Mouse buttons
|
|
|
|
|
|
|
|
- (void)applyButtonDown:(NSEvent *)event {
|
2019-07-02 20:57:51 +00:00
|
|
|
if(self.shouldCaptureMouse) {
|
|
|
|
if(!_mouseIsCaptured) {
|
|
|
|
_mouseIsCaptured = YES;
|
|
|
|
[NSCursor hide];
|
|
|
|
CGAssociateMouseAndMouseCursorPosition(false);
|
2021-07-16 21:21:25 +00:00
|
|
|
[self.responderDelegate scanTargetViewWouldHideOSMouseCursor:self];
|
2020-09-14 02:11:51 +00:00
|
|
|
[self.responderDelegate scanTargetViewDidCaptureMouse:self];
|
2019-09-22 17:53:38 +00:00
|
|
|
if(self.shouldUsurpCommand) {
|
2019-09-25 02:31:20 +00:00
|
|
|
((CSApplication *)[NSApplication sharedApplication]).eventDelegate = self;
|
2019-09-22 17:53:38 +00:00
|
|
|
}
|
2019-07-12 02:56:08 +00:00
|
|
|
|
|
|
|
// Don't report the first click to the delegate; treat that as merely
|
|
|
|
// an invitation to capture the cursor.
|
|
|
|
return;
|
2019-07-02 20:57:51 +00:00
|
|
|
}
|
2019-06-11 20:30:53 +00:00
|
|
|
|
|
|
|
[self.responderDelegate mouseDown:event];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)applyButtonUp:(NSEvent *)event {
|
|
|
|
if(self.shouldCaptureMouse) {
|
|
|
|
[self.responderDelegate mouseUp:event];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)mouseDown:(NSEvent *)event {
|
|
|
|
[self applyButtonDown:event];
|
|
|
|
[super mouseDown:event];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)rightMouseDown:(NSEvent *)event {
|
|
|
|
[self applyButtonDown:event];
|
|
|
|
[super rightMouseDown:event];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)otherMouseDown:(NSEvent *)event {
|
|
|
|
[self applyButtonDown:event];
|
|
|
|
[super otherMouseDown:event];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)mouseUp:(NSEvent *)event {
|
|
|
|
[self applyButtonUp:event];
|
|
|
|
[super mouseUp:event];
|
|
|
|
}
|
|
|
|
|
2023-05-16 20:40:09 +00:00
|
|
|
- (void)rightMouseUp:(NSEvent *)event {
|
2019-06-11 20:30:53 +00:00
|
|
|
[self applyButtonUp:event];
|
|
|
|
[super rightMouseUp:event];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)otherMouseUp:(NSEvent *)event {
|
|
|
|
[self applyButtonUp:event];
|
|
|
|
[super otherMouseUp:event];
|
|
|
|
}
|
|
|
|
|
2015-07-17 00:40:46 +00:00
|
|
|
@end
|