Browse Source

MacOs Cursor fix

-Fix: MacOs cursor now hides if a custom cursor is defined
-Fix: Cursor also reappears outside the View
marauder2k7 5 years ago
parent
commit
8c746cbf0c

+ 21 - 3
engine/source/platformOSX/osxInput.mm

@@ -296,12 +296,18 @@ U16 Input::getAscii(U16 keyCode, KEY_STATE keyState)
 // Not yet implemented. Will resolve in the next platform update
 // Not yet implemented. Will resolve in the next platform update
 void Input::pushCursor(S32 cursorID)
 void Input::pushCursor(S32 cursorID)
 {
 {
+    CursorManager* cm = getCursorManager();
+    if(cm)
+        cm->pushCursor(cursorID);
 }
 }
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 // Not yet implemented. Will resolve in the next platform update
 // Not yet implemented. Will resolve in the next platform update
 void Input::popCursor()
 void Input::popCursor()
 {
 {
+    CursorManager* cm = getCursorManager();
+    if(cm)
+        cm->popCursor();
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
@@ -336,22 +342,34 @@ S32 Input::getDoubleClickHeight()
 // Not yet implemented. Will resolve in the next platform update
 // Not yet implemented. Will resolve in the next platform update
 void Input::setCursorPos(S32 x, S32 y)
 void Input::setCursorPos(S32 x, S32 y)
 {
 {
+    
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 // Not yet implemented. Will resolve in the next platform update
 // Not yet implemented. Will resolve in the next platform update
 void Input::setCursorState(bool on)
 void Input::setCursorState(bool on)
 {
 {
-
+    on ? [NSCursor unhide] : [NSCursor hide];
 }
 }
 
 
+
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 // Not yet implemented. Will resolve in the next platform update
 // Not yet implemented. Will resolve in the next platform update
 void Input::setCursorShape(U32 cursorID)
 void Input::setCursorShape(U32 cursorID)
 {
 {
-
+    NSCursor *cur;
+    switch (cursorID) {
+        case CursorManager::curArrow:
+            cur = [NSCursor arrowCursor];
+            [cur set];
+        default:
+            cur = [NSCursor arrowCursor];
+            [cur set];
+    }
+    
 }
 }
 
 
+
 #pragma mark ---- Platform Namespace Functions ----
 #pragma mark ---- Platform Namespace Functions ----
 
 
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
@@ -654,4 +672,4 @@ static U8 VcodeRemap[256] =
 U8 TranslateOSKeyCode(U8 vcode)
 U8 TranslateOSKeyCode(U8 vcode)
 {
 {
     return VcodeRemap[vcode];
     return VcodeRemap[vcode];
-}
+}

+ 13 - 0
engine/source/platformOSX/osxTorqueView.mm

@@ -370,6 +370,18 @@
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
+- (void)mouseEntered:(NSEvent *)event
+{
+    if (!Canvas->getUseNativeCursor())
+    {
+        [NSCursor hide];
+    }
+}
+
+-(void)mouseExited:(NSEvent *)event
+{
+    [NSCursor unhide];
+}
 // Default otherMouseDown override
 // Default otherMouseDown override
 - (void)mouseMoved:(NSEvent *)event
 - (void)mouseMoved:(NSEvent *)event
 {
 {
@@ -388,6 +400,7 @@
     U32 modifiers = 0;
     U32 modifiers = 0;
     [self getModifierKey:modifiers event:event];
     [self getModifierKey:modifiers event:event];
     
     
+    
     // Move the cursor
     // Move the cursor
     Canvas->setCursorPos(Point2I((S32) location.x, (S32) location.y));
     Canvas->setCursorPos(Point2I((S32) location.x, (S32) location.y));
     
     

+ 1 - 1
engine/source/platformOSX/osxWindow.mm

@@ -204,4 +204,4 @@ bool Platform::openWebBrowser( const char* webAddress )
         Con::errorf("Platform::openWebBrowser could not open web address:%s", webAddress);
         Con::errorf("Platform::openWebBrowser could not open web address:%s", webAddress);
 
 
     return result;
     return result;
-}
+}

+ 7 - 0
modules/Sandbox/1/gui/guiProfiles.cs

@@ -42,6 +42,13 @@ new GuiCursor(DefaultCursor)
     bitmapName = "^Sandbox/gui/images/defaultCursor";
     bitmapName = "^Sandbox/gui/images/defaultCursor";
 };
 };
 
 
+new GuiCursor(DefaultMacCursor)
+{
+    hotSpot = "4 4";
+    renderOffset = "0 0";
+    bitmapName = "^Sandbox/gui/images/defaultMacCursor";
+};
+
 //---------------------------------------------------------------------------------------------
 //---------------------------------------------------------------------------------------------
 // GuiDefaultProfile is a special profile that all other profiles inherit defaults from. It
 // GuiDefaultProfile is a special profile that all other profiles inherit defaults from. It
 // must exist.
 // must exist.

BIN
modules/Sandbox/1/gui/images/defaultMacCursor.png


+ 1 - 1
modules/TruckToy/1/main.cs

@@ -58,7 +58,7 @@ function TruckToy::create( %this )
     addFlagOption("Front Wheel Drive", "setFrontWheelDrive", TruckToy.FrontWheelDrive, false, "Whether the motor on the front wheel is active or not." );
     addFlagOption("Front Wheel Drive", "setFrontWheelDrive", TruckToy.FrontWheelDrive, false, "Whether the motor on the front wheel is active or not." );
     addFlagOption("Rear Wheel Drive", "setRearWheelDrive", TruckToy.RearWheelDrive, false, "Whether the motor on the rear wheel is active or not." );
     addFlagOption("Rear Wheel Drive", "setRearWheelDrive", TruckToy.RearWheelDrive, false, "Whether the motor on the rear wheel is active or not." );
     addFlagOption("Rotate Camera", "setRotateCamera", TruckToy.RotateCamera, true, "Whether the rotate the camera that is mounted to the truck or not." );
     addFlagOption("Rotate Camera", "setRotateCamera", TruckToy.RotateCamera, true, "Whether the rotate the camera that is mounted to the truck or not." );
-	Canvas.setCursor(DefaultCursor);
+	Canvas.setCursor(DefaultMacCursor);
     // Reset the toy.
     // Reset the toy.
     %this.reset();
     %this.reset();