[SOLVED] Help requested: Screenshot taken but disabled buttons still visible
Hi everyone, I was hoping someone could help me with the following. I have a button that saves a screenshot PNG to the Downloads folder when you press it.
What I want is for the button to disappear after it is pressed, so the screenshot does not include the two menu buttons called “%SaveReport” and “%BackMainMenu”.
The code for the save button is listed below:
`
func _on_SaveReport_pressed():
<span style="color:#323232;">$"%SaveReport".visible = false
</span><span style="color:#323232;">
</span><span style="color:#323232;">$"%BackMainMenu".visible = false
</span><span style="color:#323232;">
</span><span style="color:#323232;">print("I've disabled the buttons")
</span><span style="color:#323232;">print("That means the screenshot SHOULD be button free")
</span><span style="color:#323232;">
</span><span style="color:#323232;">take_screenshot()
</span><span style="color:#323232;">
</span><span style="color:#323232;">$"%SaveReport".visible = true
</span><span style="color:#323232;">$"%BackMainMenu".visible = true
</span>
`
As you can see, it calls the take_screenshot() function which is listed above:
`
func take_screenshot(): image = get_viewport().get_texture().get_image()
<span style="color:#323232;">if OS.get_name() == "Web" or OS.has_feature('JavaScript'):
</span><span style="color:#323232;"> print("We're on the web")
</span><span style="color:#323232;"> # We're on the web
</span><span style="color:#323232;">
</span><span style="color:#323232;"> image.clear_mipmaps()
</span><span style="color:#323232;">
</span><span style="color:#323232;"> var buffer = image.save_png_to_buffer()
</span><span style="color:#323232;"> JavaScriptBridge.download_buffer(buffer, fileName)
</span><span style="color:#323232;">
</span><span style="color:#323232;">if OS.get_name() != "Web" or !OS.has_feature('JavaScript'):
</span><span style="color:#323232;"> # We're not on the web
</span><span style="color:#323232;"> print("We're not on the web")
</span><span style="color:#323232;">
</span><span style="color:#323232;"> var docs = OS.get_environment("HOME") + "/Documents"
</span><span style="color:#323232;">
</span><span style="color:#323232;"> var title = str(docs + "/results",global_ints.observed_person_name, global_ints.observation_minutes,".png")
</span><span style="color:#323232;">
</span><span style="color:#323232;"> print(title)
</span><span style="color:#323232;">
</span><span style="color:#323232;"> var _saveimage = image.save_png(title)
</span><span style="color:#323232;">
</span><span style="color:#323232;"> if OS.get_name() != "OSX":
</span><span style="color:#323232;"> print("We're not on MacOS")
</span><span style="color:#323232;"> var _openfolder = OS.shell_open(docs)
</span><span style="color:#323232;">
</span><span style="color:#323232;"> if OS.get_name() == "OSX":
</span><span style="color:#323232;"> print("We're on MacOS")
</span><span style="color:#323232;">
</span><span style="color:#323232;"> var _openfolder = OS.shell_open("file://" + docs)
</span>
`
The code works. The screenshot is taken and it’s saved to the Downloads folder and MacOS/Windows/Linux open up the Downloads folder straight after.
For the life of me, I can’t figure out why the Back & Screenshot buttons ( “%SaveReport” and “%BackMainMenu”) that I turn invisible BEFORE I call take_screenshot() end up being in the screenshot. Every single time.
Anyone have any ideas?
Thank you!
Add comment