Revision: 7854
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7854&view=rev
Author:   hofman
Date:     2012-12-15 12:41:15 +0000 (Sat, 15 Dec 2012)
Log Message:
-----------
Pass on cancelOperation: to window controller rather than using a custom method 
from full screen windows.

Let the window controller decide what to do with right mouse down in full 
screen mode through a delegate method declared in category.

Modified Paths:
--------------
    trunk/SKFullScreenWindow.h
    trunk/SKFullScreenWindow.m
    trunk/SKMainWindowController.h
    trunk/SKMainWindowController.m
    trunk/SKMainWindowController_Actions.m
    trunk/SKSideWindow.h
    trunk/SKSideWindow.m

Modified: trunk/SKFullScreenWindow.h
===================================================================
--- trunk/SKFullScreenWindow.h  2012-12-14 23:23:57 UTC (rev 7853)
+++ trunk/SKFullScreenWindow.h  2012-12-15 12:41:15 UTC (rev 7854)
@@ -56,3 +56,8 @@
 
 @interface SKMainFullScreenWindow : SKFullScreenWindow
 @end
+
+
+@interface NSWindowController (SKMainFullScreenWindow)
+- (BOOL)handleRightMouseDown:(NSEvent *)theEvent;
+@end

Modified: trunk/SKFullScreenWindow.m
===================================================================
--- trunk/SKFullScreenWindow.m  2012-12-14 23:23:57 UTC (rev 7853)
+++ trunk/SKFullScreenWindow.m  2012-12-15 12:41:15 UTC (rev 7854)
@@ -37,8 +37,6 @@
  */
 
 #import "SKFullScreenWindow.h"
-#import "SKMainWindowController.h"
-#import "SKMainWindowController_Actions.h"
 #import "SKStringConstants.h"
 
 #define DURATION 0.25
@@ -175,18 +173,17 @@
 - (BOOL)canBecomeMainWindow { return YES; }
 
 - (void)sendEvent:(NSEvent *)theEvent {
-    if ([theEvent type] == NSLeftMouseDown || [theEvent type] == 
NSRightMouseDown) {
-        SKMainWindowController *wc = (SKMainWindowController *)[self 
windowController];
-        if ([wc interactionMode] == SKPresentationMode && ([theEvent type] == 
NSRightMouseDown || ([theEvent modifierFlags] & NSControlKeyMask))) {
-            [wc doGoToPreviousPage:self];
+    if ([theEvent type] == NSRightMouseDown || ([theEvent type] == 
NSLeftMouseDown && ([theEvent modifierFlags] & NSControlKeyMask))) {
+        if ([[self windowController] 
respondsToSelector:@selector(handleRightMouseDown:)] && [[self 
windowController] handleRightMouseDown:theEvent])
             return;
-        }
     }
     [super sendEvent:theEvent];
 }
 
 - (void)cancelOperation:(id)sender {
-    [(SKMainWindowController *)[self windowController] exitFullscreen:self];
+    // for some reason this action method is not passed on to the window 
controller, so we do this ourselves
+    if ([[self windowController] 
respondsToSelector:@selector(cancelOperation:)])
+        [[self windowController] cancelOperation:self];
 }
 
 @end

Modified: trunk/SKMainWindowController.h
===================================================================
--- trunk/SKMainWindowController.h      2012-12-14 23:23:57 UTC (rev 7853)
+++ trunk/SKMainWindowController.h      2012-12-15 12:41:15 UTC (rev 7854)
@@ -276,8 +276,6 @@
 
 @property (nonatomic, readonly) BOOL leftSidePaneIsOpen, rightSidePaneIsOpen;
 
-- (void)closeSideWindow:(SKSideWindow *)sideWindow;
-
 - (void)displayTocViewAnimating:(BOOL)animate;
 - (void)displayThumbnailViewAnimating:(BOOL)animate;
 - (void)displayFindViewAnimating:(BOOL)animate;

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2012-12-14 23:23:57 UTC (rev 7853)
+++ trunk/SKMainWindowController.m      2012-12-15 12:41:15 UTC (rev 7854)
@@ -1008,18 +1008,6 @@
     return state == NSDrawerOpenState || state == NSDrawerOpeningState;
 }
 
-- (void)closeSideWindow:(SKSideWindow *)sideWindow {    
-    if ([sideWindow state] == NSDrawerOpenState || [sideWindow state] == 
NSDrawerOpeningState) {
-        if (sideWindow == leftSideWindow) {
-            [self toggleLeftSidePane:self];
-        } else if (sideWindow == rightSideWindow) {
-            [self toggleRightSidePane:self];
-        }
-    } else if ([self interactionMode] == SKPresentationMode) {
-        [self exitFullscreen:nil];
-    }
-}
-
 - (NSArray *)notes {
     return [[notes copy] autorelease];
 }
@@ -1617,6 +1605,14 @@
     [self removeBlankingWindows];
 }
 
+- (BOOL)handleRightMouseDown:(NSEvent *)theEvent {
+    if ([self interactionMode] == SKPresentationMode) {
+        [self doGoToPreviousPage:nil];
+        return YES;
+    }
+    return NO;
+}
+
 #pragma mark Swapping tables
 
 - (void)displayTocViewAnimating:(BOOL)animate {

Modified: trunk/SKMainWindowController_Actions.m
===================================================================
--- trunk/SKMainWindowController_Actions.m      2012-12-14 23:23:57 UTC (rev 
7853)
+++ trunk/SKMainWindowController_Actions.m      2012-12-15 12:41:15 UTC (rev 
7854)
@@ -1061,4 +1061,21 @@
        }
 }
 
+- (void)cancelOperation:(id)sender {
+    // passed on from SKSideWindow or SKFullScreenWindow
+    if ([self interactionMode] != SKNormalMode) {
+        if (sender == [self window]) {
+            [self exitFullscreen:sender];
+        } else if (sender == leftSideWindow || sender == rightSideWindow) {
+            NSDrawerState state = [(SKSideWindow *)sender state];
+            if (state == NSDrawerClosedState || state == NSDrawerClosingState)
+                [self exitFullscreen:sender];
+            else if (sender == leftSideWindow)
+                [self toggleLeftSidePane:sender];
+            else if (sender == rightSideWindow)
+                [self toggleRightSidePane:sender];
+        }
+    }
+}
+
 @end

Modified: trunk/SKSideWindow.h
===================================================================
--- trunk/SKSideWindow.h        2012-12-14 23:23:57 UTC (rev 7853)
+++ trunk/SKSideWindow.h        2012-12-15 12:41:15 UTC (rev 7854)
@@ -77,8 +77,3 @@
 }
 - (id)initWithFrame:(NSRect)frameRect edge:(NSRectEdge)anEdge;
 @end
-
-
-@interface NSWindowController (SKSideWindowController)
-- (void)closeSideWindow:(SKSideWindow *)sideWindow;
-@end

Modified: trunk/SKSideWindow.m
===================================================================
--- trunk/SKSideWindow.m        2012-12-14 23:23:57 UTC (rev 7853)
+++ trunk/SKSideWindow.m        2012-12-15 12:41:15 UTC (rev 7854)
@@ -227,15 +227,16 @@
 }
 
 - (void)keyDown:(NSEvent *)theEvent {
-    if ([theEvent firstCharacter] == 'p' && [theEvent 
deviceIndependentModifierFlags] == 0 && enabled == NO && [controller 
respondsToSelector:@selector(closeSideWindow:)])
-        [controller closeSideWindow:self];
+    if ([theEvent firstCharacter] == 'p' && [theEvent 
deviceIndependentModifierFlags] == 0 && enabled == NO)
+        [self cancelOperation:self];
     else
         [super keyDown:theEvent];
 }
 
 - (void)cancelOperation:(id)sender {
-    if ([controller respondsToSelector:@selector(closeSideWindow:)])
-        [controller closeSideWindow:self];
+    // for some reason this action method is not passed on up the responder 
chain, so we do this ourselves
+    if ([controller respondsToSelector:@selector(cancelOperation:)])
+        [controller cancelOperation:self];
 }
     
 - (NSResponder *)nextResponder {

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to