Is drag and dropping files onto a Godot 4 game possible?

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

I am making a game in Godot that needs a feature to drag and drop a file. I’ve been googling alot about this but I can’t find it in the documentation. I have found old github discussions about this for Godot 2 and 3 but they all use outdated code inconclusive and vague. Does anybody know if it’s possible in Godot 4?

:bust_in_silhouette: Reply From: Merlin1846

Yes, it is still possible however due to Godot 4 supporting multiple windows this is now under the window class. Here’s an example pulled from the docs.

func _ready():
   get_viewport().files_dropped.connect(on_files_dropped)

func on_files_dropped(files):
   print(files)