how to script " if mouse not inside screen"?

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

how to script " if mouse not inside screen"?

:bust_in_silhouette: Reply From: astroboogie

MainLoop provides these constants:

  • NOTIFICATION_WM_MOUSE_ENTER
  • NOTIFICATION_WM_MOUSE_EXIT

You can access them from the SceneTree with get_tree().

:bust_in_silhouette: Reply From: eod

Here’s a specific example you can put in your script:

func _notification(what):
    match what:
        MainLoop.NOTIFICATION_WM_MOUSE_EXIT:
            print("Mouse has left game window")
        MainLoop.NOTIFICATION_WM_MOUSE_ENTER:
            print("Mouse has entered the game window")