mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-23 03:32:32 +00:00
Adds how-to-release-the-mouse instructions for Cocoa.
This commit is contained in:
parent
011d76175c
commit
f45de5b87a
@ -154,6 +154,11 @@ class MachineDocument:
|
||||
// a sheet mysteriously floating on its own. For now, use windowDidUpdate as a proxy to know that the window
|
||||
// is visible, though it's a little premature.
|
||||
func windowDidUpdate(_ notification: Notification) {
|
||||
// Grab the regular window title, if it's not already stored.
|
||||
if self.unadornedWindowTitle.count == 0 {
|
||||
self.unadornedWindowTitle = self.windowControllers[0].window!.title
|
||||
}
|
||||
|
||||
// If an interaction mode is not yet in effect, pick the proper one and display the relevant thing.
|
||||
if self.interactionMode == .notStarted {
|
||||
// If a full machine exists, just continue showing it.
|
||||
@ -613,7 +618,17 @@ class MachineDocument:
|
||||
try! pngData?.write(to: url)
|
||||
}
|
||||
|
||||
// MARK: Activity display.
|
||||
// MARK: - Window Title Updates.
|
||||
private var unadornedWindowTitle = ""
|
||||
func openGLViewDidCaptureMouse(_ view: CSOpenGLView) {
|
||||
self.windowControllers[0].window?.title = self.unadornedWindowTitle + " (press ⌘+command to release mouse)"
|
||||
}
|
||||
|
||||
func openGLViewDidReleaseMouse(_ view: CSOpenGLView) {
|
||||
self.windowControllers[0].window?.title = self.unadornedWindowTitle
|
||||
}
|
||||
|
||||
// MARK: - Activity Display.
|
||||
|
||||
private class LED {
|
||||
let levelIndicator: NSLevelIndicator
|
||||
|
@ -37,6 +37,19 @@ typedef NS_ENUM(NSInteger, CSOpenGLViewRedrawEvent) {
|
||||
*/
|
||||
- (void)openGLView:(nonnull CSOpenGLView *)view didReceiveFileAtURL:(nonnull NSURL *)URL;
|
||||
|
||||
/*!
|
||||
Announces 'capture' of the mouse — i.e. that the view is now preventing the mouse from exiting
|
||||
the window, in order to forward continuous mouse motion.
|
||||
@param view The view making the announcement.
|
||||
*/
|
||||
- (void)openGLViewDidCaptureMouse:(nonnull CSOpenGLView *)view;
|
||||
|
||||
/*!
|
||||
Announces that the mouse is no longer captured.
|
||||
@param view The view making the announcement.
|
||||
*/
|
||||
- (void)openGLViewDidReleaseMouse:(nonnull CSOpenGLView *)view;
|
||||
|
||||
@end
|
||||
|
||||
@protocol CSOpenGLViewResponderDelegate <NSObject>
|
||||
|
@ -223,6 +223,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
||||
_mouseIsCaptured = NO;
|
||||
CGAssociateMouseAndMouseCursorPosition(true);
|
||||
[NSCursor unhide];
|
||||
[self.delegate openGLViewDidReleaseMouse:self];
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,6 +282,7 @@ static CVReturn DisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt
|
||||
_mouseIsCaptured = YES;
|
||||
[NSCursor hide];
|
||||
CGAssociateMouseAndMouseCursorPosition(false);
|
||||
[self.delegate openGLViewDidCaptureMouse:self];
|
||||
|
||||
// Don't report the first click to the delegate; treat that as merely
|
||||
// an invitation to capture the cursor.
|
||||
|
Loading…
Reference in New Issue
Block a user