1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-08-08 14:25:05 +00:00

Merge pull request #436 from TomHarte/MacPaste

Corrects Mac paste pathway.
This commit is contained in:
Thomas Harte
2018-05-13 11:14:59 -04:00
committed by GitHub
3 changed files with 20 additions and 9 deletions

View File

@@ -167,7 +167,7 @@ class MachineDocument:
} }
// MARK: the pasteboard // MARK: the pasteboard
func paste(_ sender: AnyObject!) { func paste(_ sender: Any) {
let pasteboard = NSPasteboard.general let pasteboard = NSPasteboard.general
if let string = pasteboard.string(forType: .string) { if let string = pasteboard.string(forType: .string) {
self.machine.paste(string) self.machine.paste(string)

View File

@@ -32,31 +32,33 @@
@protocol CSOpenGLViewResponderDelegate <NSObject> @protocol CSOpenGLViewResponderDelegate <NSObject>
/*! /*!
Supplies a keyDown event to the delegate. Will always be called on the same queue as the other Supplies a keyDown event to the delegate.
@c CSOpenGLViewResponderDelegate methods and as -[CSOpenGLViewDelegate openGLView:didUpdateToTime:].
@param event The @c NSEvent describing the keyDown. @param event The @c NSEvent describing the keyDown.
*/ */
- (void)keyDown:(nonnull NSEvent *)event; - (void)keyDown:(nonnull NSEvent *)event;
/*! /*!
Supplies a keyUp event to the delegate. Will always be called on the same queue as the other Supplies a keyUp event to the delegate.
@c CSOpenGLViewResponderDelegate methods and as -[CSOpenGLViewDelegate openGLView:didUpdateToTime:].
@param event The @c NSEvent describing the keyUp. @param event The @c NSEvent describing the keyUp.
*/ */
- (void)keyUp:(nonnull NSEvent *)event; - (void)keyUp:(nonnull NSEvent *)event;
/*! /*!
Supplies a flagsChanged event to the delegate. Will always be called on the same queue as the other Supplies a flagsChanged event to the delegate.
@c CSOpenGLViewResponderDelegate methods and as -[CSOpenGLViewDelegate openGLView:didUpdateToTime:].
@param event The @c NSEvent describing the flagsChanged. @param event The @c NSEvent describing the flagsChanged.
*/ */
- (void)flagsChanged:(nonnull NSEvent *)event; - (void)flagsChanged:(nonnull NSEvent *)event;
/*!
Supplies a paste event to the delegate.
*/
- (void)paste:(nonnull id)sender;
@end @end
/*! /*!
Provides an OpenGL canvas with a refresh-linked update timer and manages a serial dispatch queue Provides an OpenGL canvas with a refresh-linked update timer that can forward a subset
such that a delegate may produce video and respond to keyboard events. of typical first-responder actions.
*/ */
@interface CSOpenGLView : NSOpenGLView @interface CSOpenGLView : NSOpenGLView
@@ -72,6 +74,10 @@
/// The size in pixels of the OpenGL canvas, factoring in screen pixel density and view size in points. /// The size in pixels of the OpenGL canvas, factoring in screen pixel density and view size in points.
@property (nonatomic, readonly) CGSize backingSize; @property (nonatomic, readonly) CGSize backingSize;
/*!
Locks this view's OpenGL context and makes it current, performs @c action and then unlocks
the context. @c action is performed on the calling queue.
*/
- (void)performWithGLContext:(nonnull dispatch_block_t)action; - (void)performWithGLContext:(nonnull dispatch_block_t)action;
@end @end

View File

@@ -162,6 +162,11 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
[self.responderDelegate flagsChanged:theEvent]; [self.responderDelegate flagsChanged:theEvent];
} }
- (void)paste:(id)sender
{
[self.responderDelegate paste:sender];
}
#pragma mark - NSDraggingDestination #pragma mark - NSDraggingDestination
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender