Mercurial > dwindows
comparison mac/dw.m @ 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 | 67ff39b9577c |
children | f5b79d8b0694 |
comparison
equal
deleted
inserted
replaced
1221:10f5b8645975 | 1222:aac69b11e821 |
---|---|
259 /* Button press and release event */ | 259 /* Button press and release event */ |
260 case 3: | 260 case 3: |
261 case 4: | 261 case 4: |
262 { | 262 { |
263 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; | 263 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; |
264 id view = [[[event window] contentView] superview]; | 264 NSPoint p = [NSEvent mouseLocation]; |
265 NSPoint p = [view convertPoint:[event locationInWindow] toView:object]; | |
266 NSEventType type = [event type]; | |
267 int button = 1; | 265 int button = 1; |
268 | 266 |
269 if(type == NSRightMouseDown || type == NSRightMouseUp) | 267 if([event isMemberOfClass:[NSEvent class]]) |
270 { | 268 { |
271 button = 2; | 269 id view = [[[event window] contentView] superview]; |
272 } | 270 NSEventType type = [event type]; |
273 else if(type == NSOtherMouseDown || type == NSOtherMouseUp) | 271 |
274 { | 272 p = [view convertPoint:[event locationInWindow] toView:object]; |
275 button = 3; | 273 |
274 if(type == NSRightMouseDown || type == NSRightMouseUp) | |
275 { | |
276 button = 2; | |
277 } | |
278 else if(type == NSOtherMouseDown || type == NSOtherMouseUp) | |
279 { | |
280 button = 3; | |
281 } | |
276 } | 282 } |
277 | 283 |
278 return buttonfunc(object, (int)p.x, (int)p.y, button, handler->data); | 284 return buttonfunc(object, (int)p.x, (int)p.y, button, handler->data); |
279 } | 285 } |
280 /* Motion notify event */ | 286 /* Motion notify event */ |
6083 [item setToolTip:[NSString stringWithUTF8String:bubbletext]]; | 6089 [item setToolTip:[NSString stringWithUTF8String:bubbletext]]; |
6084 [item setTarget:handle]; | 6090 [item setTarget:handle]; |
6085 [item setEnabled:YES]; | 6091 [item setEnabled:YES]; |
6086 [item setHighlightMode:YES]; | 6092 [item setHighlightMode:YES]; |
6087 [item sendActionOn:(NSLeftMouseUpMask|NSLeftMouseDownMask|NSRightMouseUpMask|NSRightMouseDownMask)]; | 6093 [item sendActionOn:(NSLeftMouseUpMask|NSLeftMouseDownMask|NSRightMouseUpMask|NSRightMouseDownMask)]; |
6094 [item setAction:@selector(mouseDown:)]; | |
6088 dw_window_set_data(handle, "_dw_taskbar", item); | 6095 dw_window_set_data(handle, "_dw_taskbar", item); |
6089 } | 6096 } |
6090 | 6097 |
6091 /* | 6098 /* |
6092 * Deletes an icon from the taskbar. | 6099 * Deletes an icon from the taskbar. |