changeset 1222:aac69b11e821

Fix to get button press events working from the task/statusbar on Mac. Need to check that the parameter is an NSEvent in the handler, because... When calling the selector like this it will actually be the NSStatusItem.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 10 Oct 2011 02:54:27 +0000
parents 10f5b8645975
children 1255ba41adad
files mac/dw.m
diffstat 1 files changed, 17 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mac/dw.m	Mon Oct 10 02:04:17 2011 +0000
+++ b/mac/dw.m	Mon Oct 10 02:54:27 2011 +0000
@@ -261,18 +261,24 @@
             case 4:
             {
                 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
-                id view = [[[event window] contentView] superview];
-                NSPoint p = [view convertPoint:[event locationInWindow] toView:object];
-                NSEventType type = [event type];
+                NSPoint p = [NSEvent mouseLocation]; 
                 int button = 1;
-
-                if(type == NSRightMouseDown || type == NSRightMouseUp)
+                
+                if([event isMemberOfClass:[NSEvent class]])
                 {
-                    button = 2;
-                }
-                else if(type == NSOtherMouseDown || type == NSOtherMouseUp)
-                {
-                    button = 3;
+                    id view = [[[event window] contentView] superview];
+                    NSEventType type = [event type];
+                    
+                    p = [view convertPoint:[event locationInWindow] toView:object];
+
+                    if(type == NSRightMouseDown || type == NSRightMouseUp)
+                    {
+                        button = 2;
+                    }
+                    else if(type == NSOtherMouseDown || type == NSOtherMouseUp)
+                    {
+                        button = 3;
+                    }
                 }
 
                 return buttonfunc(object, (int)p.x, (int)p.y, button, handler->data);
@@ -6085,6 +6091,7 @@
     [item setEnabled:YES];
     [item setHighlightMode:YES];
     [item sendActionOn:(NSLeftMouseUpMask|NSLeftMouseDownMask|NSRightMouseUpMask|NSRightMouseDownMask)];
+    [item setAction:@selector(mouseDown:)];
     dw_window_set_data(handle, "_dw_taskbar", item);
 }