diff options
author | Haoyu Qiu <timothyqiu32@gmail.com> | 2020-01-31 12:40:13 +0800 |
---|---|---|
committer | Haoyu Qiu <timothyqiu32@gmail.com> | 2020-01-31 14:16:06 +0800 |
commit | 8f881847c05b596e587f87cc682ce0307a52af34 (patch) | |
tree | 0bb4e5b1fde647a4857c85bbe86afbf112642339 /platform/osx | |
parent | 3c3ed67c3944a555d18fa8b68603f3a68416e27e (diff) |
Adds extra cursors for macOS
Before, plain arrow cursor or unsuitable ones were used.
Diffstat (limited to 'platform/osx')
-rw-r--r-- | platform/osx/os_osx.mm | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 6a214b8669..53fe11b3bb 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -115,6 +115,20 @@ static Vector2 get_mouse_pos(NSPoint locationInWindow, CGFloat backingScaleFacto return Vector2(mouse_x, mouse_y); } +static NSCursor *cursorFromSelector(SEL selector, SEL fallback = nil) { + if ([NSCursor respondsToSelector:selector]) { + id object = [NSCursor performSelector:selector]; + if ([object isKindOfClass:[NSCursor class]]) { + return object; + } + } + if (fallback) { + // Fallback should be a reasonable default, no need to check. + return [NSCursor performSelector:fallback]; + } + return [NSCursor arrowCursor]; +} + @interface GodotApplication : NSApplication @end @@ -1813,15 +1827,15 @@ void OS_OSX::set_cursor_shape(CursorShape p_shape) { case CURSOR_BUSY: [[NSCursor arrowCursor] set]; break; case CURSOR_DRAG: [[NSCursor closedHandCursor] set]; break; case CURSOR_CAN_DROP: [[NSCursor openHandCursor] set]; break; - case CURSOR_FORBIDDEN: [[NSCursor arrowCursor] set]; break; - case CURSOR_VSIZE: [[NSCursor resizeUpDownCursor] set]; break; - case CURSOR_HSIZE: [[NSCursor resizeLeftRightCursor] set]; break; - case CURSOR_BDIAGSIZE: [[NSCursor arrowCursor] set]; break; - case CURSOR_FDIAGSIZE: [[NSCursor arrowCursor] set]; break; + case CURSOR_FORBIDDEN: [[NSCursor operationNotAllowedCursor] set]; break; + case CURSOR_VSIZE: [cursorFromSelector(@selector(_windowResizeNorthSouthCursor), @selector(resizeUpDownCursor)) set]; break; + case CURSOR_HSIZE: [cursorFromSelector(@selector(_windowResizeEastWestCursor), @selector(resizeLeftRightCursor)) set]; break; + case CURSOR_BDIAGSIZE: [cursorFromSelector(@selector(_windowResizeNorthEastSouthWestCursor)) set]; break; + case CURSOR_FDIAGSIZE: [cursorFromSelector(@selector(_windowResizeNorthWestSouthEastCursor)) set]; break; case CURSOR_MOVE: [[NSCursor arrowCursor] set]; break; case CURSOR_VSPLIT: [[NSCursor resizeUpDownCursor] set]; break; case CURSOR_HSPLIT: [[NSCursor resizeLeftRightCursor] set]; break; - case CURSOR_HELP: [[NSCursor arrowCursor] set]; break; + case CURSOR_HELP: [cursorFromSelector(@selector(_helpCursor)) set]; break; default: { }; } |