diff options
-rw-r--r-- | src/cocoa/mod.rs | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/src/cocoa/mod.rs b/src/cocoa/mod.rs index 506967b..7125720 100644 --- a/src/cocoa/mod.rs +++ b/src/cocoa/mod.rs @@ -630,30 +630,29 @@ impl Window { pub fn set_cursor(&self, cursor: MouseCursor) { let cursor_name = match cursor { - MouseCursor::Arrow => "arrowCursor", + MouseCursor::Arrow | MouseCursor::Default => "arrowCursor", + MouseCursor::Hand => "pointingHandCursor", + MouseCursor::Grabbing | MouseCursor::Grab => "closedHandCursor", MouseCursor::Text => "IBeamCursor", - MouseCursor::ContextMenu => "contextualMenuCursor", + MouseCursor::VerticalText => "IBeamCursorForVerticalLayout", MouseCursor::Copy => "dragCopyCursor", - MouseCursor::Crosshair => "crosshairCursor", - MouseCursor::Default => "arrowCursor", - MouseCursor::Grabbing => "openHandCursor", - MouseCursor::Hand | MouseCursor::Grab => "pointingHandCursor", - MouseCursor::NoDrop => "operationNotAllowedCursor", - MouseCursor::NotAllowed => "operationNotAllowedCursor", MouseCursor::Alias => "dragLinkCursor", - - - /// Resize cursors - MouseCursor::EResize | MouseCursor::NResize | - MouseCursor::NeResize | MouseCursor::NwResize | - MouseCursor::SResize | MouseCursor::SeResize | - MouseCursor::SwResize | MouseCursor::WResize | - MouseCursor::EwResize | MouseCursor::ColResize | - MouseCursor::NsResize | MouseCursor::RowResize | - MouseCursor::NwseResize | MouseCursor::NeswResize => "arrowCursor", + MouseCursor::NotAllowed | MouseCursor::NoDrop => "operationNotAllowedCursor", + MouseCursor::ContextMenu => "contextualMenuCursor", + MouseCursor::Crosshair => "crosshairCursor", + MouseCursor::EResize => "resizeRightCursor", + MouseCursor::NResize => "resizeUpCursor", + MouseCursor::WResize => "resizeLeftCursor", + MouseCursor::SResize => "resizeDownCursor", + MouseCursor::EwResize | MouseCursor::ColResize => "resizeLeftRightCursor", + MouseCursor::NsResize | MouseCursor::RowResize => "resizeUpDownCursor", /// TODO: Find appropriate OSX cursors - MouseCursor::Cell | MouseCursor::VerticalText | MouseCursor::NoneCursor | + MouseCursor::NeResize | MouseCursor::NwResize | + MouseCursor::SeResize | MouseCursor::SwResize | + MouseCursor::NwseResize | MouseCursor::NeswResize | + + MouseCursor::Cell | MouseCursor::NoneCursor | MouseCursor::Wait | MouseCursor::Progress | MouseCursor::Help | MouseCursor::Move | MouseCursor::AllScroll | MouseCursor::ZoomIn | MouseCursor::ZoomOut => "arrowCursor", @@ -668,7 +667,20 @@ impl Window { } pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String> { - unimplemented!(); + let cls = Class::get("NSCursor").unwrap(); + match state { + CursorState::Normal => { + let _: () = unsafe { msg_send![cls, unhide] }; + Ok(()) + }, + CursorState::Hide => { + let _: () = unsafe { msg_send![cls, hide] }; + Ok(()) + }, + CursorState::Grab => { + Err("Mouse grabbing is unimplemented".to_string()) + } + } } pub fn hidpi_factor(&self) -> f32 { |