How to make mouse "Pointing hand" for all buttons

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Keeyan

I want all the buttons in my game to have the mouse_default_cursor_shape property set to “Pointing hand”.

I can manually go and change them, but I would rather it be set by default.

I’ve been using themes to style the buttons so far, but I can’t find a way to set the mouse pointer (or non-style options, like width) through a theme. Is this possible?

1 Like
:bust_in_silhouette: Reply From: Calinou

You can create a script that extends Button, add a class_name to it and add this custom class_name-based node to your scenes:

extends Button
class_name MyButton

func _ready():
    mouse_default_cursor_shape = CURSOR_POINTING_HAND

In the scene tree dock, right-click a node and use Change Type to convert Buttons to MyButtons.

Thanks Calinou, that does the trick :slight_smile: Although I was hoping for a theme option or something, that way I could just use the default buttons. But I guess that’s not possible atm.

Keeyan | 2021-06-25 20:35

1 Like