Reset the cursor with Input.set_custom_mouse_cursor(null)

This commit is contained in:
Guilherme Felipe 2018-05-10 19:17:00 -03:00
parent 1ec2fa42f8
commit 50a0220d2d
4 changed files with 19 additions and 1 deletions

View file

@ -284,7 +284,7 @@
<argument index="2" name="hotspot" type="Vector2" default="Vector2( 0, 0 )">
</argument>
<description>
Set a custom mouse cursor image, which is only visible inside the game window. The hotspot can also be specified. See enum [code]CURSOR_*[/code] for the list of shapes.
Set a custom mouse cursor image, which is only visible inside the game window. The hotspot can also be specified. Passing [code]null[/code] to the image parameter resets to the system cursor. See enum [code]CURSOR_*[/code] for the list of shapes.
</description>
</method>
<method name="set_mouse_mode">

View file

@ -1594,6 +1594,11 @@ void OS_OSX::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
if (p_shape == CURSOR_ARROW) {
[cursor set];
}
} else {
// Reset to default system cursor
cursors[p_shape] = NULL;
cursor_shape = CURSOR_MAX;
set_cursor_shape(p_shape);
}
}

View file

@ -2117,6 +2117,11 @@ void OS_Windows::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shap
if (hXorMask != NULL) {
DeleteObject(hXorMask);
}
} else {
// Reset to default system cursor
cursors[p_shape] = NULL;
cursor_shape = CURSOR_MAX;
set_cursor_shape(p_shape);
}
}

View file

@ -2486,6 +2486,14 @@ void OS_X11::set_custom_mouse_cursor(const RES &p_cursor, CursorShape p_shape, c
if (p_shape == CURSOR_ARROW) {
XDefineCursor(x11_display, x11_window, cursors[p_shape]);
}
} else {
// Reset to default system cursor
if (img[p_shape]) {
cursors[p_shape] = XcursorImageLoadCursor(x11_display, img[p_shape]);
}
current_cursor = CURSOR_MAX;
set_cursor_shape(p_shape);
}
}