aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFelix Kaaman <trundmatu@gmail.com>2015-04-14 22:15:55 +0200
committerFelix Kaaman <trundmatu@gmail.com>2015-04-17 18:01:06 +0200
commite2944410497c0c76642170e7a6d5a69b6544ff43 (patch)
tree5702cdc5badef91daf1e5694761b2b60063b68a0 /src
parent677e69fd3aa29fc01a836e1b6d58788ecfc89ab0 (diff)
downloadglutin-e2944410497c0c76642170e7a6d5a69b6544ff43.tar.gz
glutin-e2944410497c0c76642170e7a6d5a69b6544ff43.zip
Add mouse hiding and more cursors for Cocoa
Diffstat (limited to 'src')
-rw-r--r--src/cocoa/mod.rs52
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 {