How does a popup (modal) communicate with global script

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

Hi,

i have only one script in the root-node.

extends Panel

var quit_requested = false	# if user wants to quit the game

...

func _process(delta):
 
   if quit_requested == true:
	  get_tree().quit()
	  pass

   if Input.is_action_just_pressed("MainMenuPressed"):
	  mainmenu.show_modal()
	  pass

func _on_BeendenButton_pressed():	#Main Menu
   quit_requested = true
   mainmenu.hide()
   pass # replace with function body

mainmenu is a popup-node
the quit-button (BeendenButton) is in this popup
The problem here is, that quit_requested is not set to true. So it seems that I dont know how the popup can change a global variable.
Before I tried a direct get_tree().quit() instead of quit_requested = true but that didnt work, maybe the same problem.

:bust_in_silhouette: Reply From: ColossalGnome

You should be using signals for this :slight_smile:

thank you that was helpful, although I didnt manage to make it run yet. The problem I encountered now is, that never mind where I click, the popup hides. I checked “exlusive” property as it is written, but I can still click everywhere and it closes.

mr.fies | 2018-03-31 08:02