Mercurial > dwindows
comparison mac/dw.m @ 2617:d17e3fb76bde
dw_menu_popup() should also set handle NULL and add safety checks if missing.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 23 Jul 2021 19:42:06 +0000 |
parents | ac51cbdcfbe5 |
children | 156ad91481eb |
comparison
equal
deleted
inserted
replaced
2616:a256caa5034c | 2617:d17e3fb76bde |
---|---|
9430 * x: X coordinate. | 9430 * x: X coordinate. |
9431 * y: Y coordinate. | 9431 * y: Y coordinate. |
9432 */ | 9432 */ |
9433 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) | 9433 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y) |
9434 { | 9434 { |
9435 NSMenu *thismenu = (NSMenu *)*menu; | 9435 if(menu) |
9436 id object = parent; | 9436 { |
9437 NSView *view = [object isKindOfClass:[NSWindow class]] ? [object contentView] : parent; | 9437 NSMenu *thismenu = (NSMenu *)*menu; |
9438 NSWindow *window = [view window]; | 9438 id object = parent; |
9439 NSEvent *event = [DWApp currentEvent]; | 9439 NSView *view = [object isKindOfClass:[NSWindow class]] ? [object contentView] : parent; |
9440 if(!window) | 9440 NSWindow *window = [view window]; |
9441 window = [event window]; | 9441 NSEvent *event = [DWApp currentEvent]; |
9442 [thismenu autorelease]; | 9442 if(!window) |
9443 NSPoint p = NSMakePoint(x, [[NSScreen mainScreen] frame].size.height - y); | 9443 window = [event window]; |
9444 NSEvent* fake = [NSEvent mouseEventWithType:DWEventTypeRightMouseDown | 9444 [thismenu autorelease]; |
9445 location:_dw_windowPointFromScreen(window, p) | 9445 NSPoint p = NSMakePoint(x, [[NSScreen mainScreen] frame].size.height - y); |
9446 modifierFlags:0 | 9446 NSEvent* fake = [NSEvent mouseEventWithType:DWEventTypeRightMouseDown |
9447 timestamp:[event timestamp] | 9447 location:_dw_windowPointFromScreen(window, p) |
9448 windowNumber:[window windowNumber] | 9448 modifierFlags:0 |
9449 context:[NSGraphicsContext currentContext] | 9449 timestamp:[event timestamp] |
9450 eventNumber:1 | 9450 windowNumber:[window windowNumber] |
9451 clickCount:1 | 9451 context:[NSGraphicsContext currentContext] |
9452 pressure:0.0]; | 9452 eventNumber:1 |
9453 [NSMenu popUpContextMenu:thismenu withEvent:fake forView:view]; | 9453 clickCount:1 |
9454 pressure:0.0]; | |
9455 [NSMenu popUpContextMenu:thismenu withEvent:fake forView:view]; | |
9456 *menu = NULL; | |
9457 } | |
9454 } | 9458 } |
9455 | 9459 |
9456 char _dw_removetilde(char *dest, const char *src) | 9460 char _dw_removetilde(char *dest, const char *src) |
9457 { | 9461 { |
9458 int z, cur=0; | 9462 int z, cur=0; |