aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-04-17 19:44:18 +0200
committertomaka <pierre.krieger1708@gmail.com>2015-04-17 19:44:18 +0200
commit4d0472f7d8629334f7782f106f5f04ce148a7d50 (patch)
tree5702cdc5badef91daf1e5694761b2b60063b68a0
parent677e69fd3aa29fc01a836e1b6d58788ecfc89ab0 (diff)
parente2944410497c0c76642170e7a6d5a69b6544ff43 (diff)
downloadglutin-4d0472f7d8629334f7782f106f5f04ce148a7d50.tar.gz
glutin-4d0472f7d8629334f7782f106f5f04ce148a7d50.zip
Merge pull request #380 from fkaa/cocoa-mouse-features
Add mouse hiding and more cursors for Cocoa
-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 {