浏览代码

only set the cursor if the mouse is over the toplevel

boombuler 7 年之前
父节点
当前提交
a3dd74fafa
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      src/OSX/Avalonia.MonoMac/TopLevelImpl.cs

+ 10 - 1
src/OSX/Avalonia.MonoMac/TopLevelImpl.cs

@@ -39,6 +39,7 @@ namespace Avalonia.MonoMac
             private NSTrackingArea _area;
             private NSCursor _cursor;
             private bool _nonUiRedrawQueued;
+            private bool _isMouseOver;
 
             public CGSize PixelSize { get; set; }
 
@@ -135,7 +136,8 @@ namespace Avalonia.MonoMac
                 if (_cursor != null)
                 {
                     AddCursorRect(Frame, _cursor);
-                    _cursor.Set();
+                    if (_isMouseOver)
+                        _cursor.Set();
                 }
             }
 
@@ -302,10 +304,17 @@ namespace Avalonia.MonoMac
 
             public override void MouseExited(NSEvent theEvent)
             {
+                _isMouseOver = false;
                 MouseEvent(theEvent, RawMouseEventType.LeaveWindow);
                 base.MouseExited(theEvent);
             }
 
+            public override void MouseEntered(NSEvent theEvent)
+            {
+                _isMouseOver = true;
+                base.MouseEntered(theEvent);
+            }
+
             void KeyboardEvent(RawKeyEventType type, NSEvent ev)
             {
                 var code = KeyTransform.TransformKeyCode(ev.KeyCode);