system
September 25, 2022, 8:10pm
1
Attention
Topic was automatically imported from the old Question2Answer platform.
Asked By
monsterousoperandi
Just want to hide the button so it’s not visible but it’s proving to be difficult.
func _ready() -> void :
_title.get("custom_fonts/font").set_size(Settings.header_2_font_size)
_content.get("custom_fonts/normal_font").set_size(Settings.narration_font_size)
self.get_close_button().disabled = true #disabled button but it's still there
self.get_close_button().hide() #does noting
self.get_close_button().visible = false #does nothing
self.get_close_button().add_color_override("disabled", Color("#00ffffff")) #also nothing
any one have any ideas? The documentation mentions using the CanvasItem.visible property but I have no idea what that means…
system
September 25, 2022, 11:34pm
2
Reply From:
jgodfrey
In 3.5, this works for me…
func _ready():
$WindowDialog.get_close_button().visible = false
$WindowDialog.popup()
1 Like
In Godot 4.x you should override the theme icon name ‘close’ to a empty Texture2D to hide the close button.
alert_dialog.add_theme_icon_override("close", Texture2D.new())
Since the icon with no texture is collapse to rect size zero. So nobody can click it anymore.
2 Likes
Yes it works, but gives me these two errors:
E 0:00:00:0560 _gdvirtual__get_height_call: Required virtual method Texture2D::_get_height must be overridden before calling.
<Sorgente C++> scene/resources/texture.h:61 @ _gdvirtual__get_height_call()
E 0:00:00:0560 _gdvirtual__get_width_call: Required virtual method Texture2D::_get_width must be overridden before calling.
<Sorgente C++> scene/resources/texture.h:60 @ _gdvirtual__get_width_call()
Both if I do it before or after the “filedialog.popup_centered()”.
tomyy
May 4, 2025, 2:52pm
6
Stumbled across this post because I too was trying to hide the “X” button and had the same problem as eliacanavera.
The reason for the errors is that Texture2D is not meant to be used directly (source: Texture2D — Godot Engine (stable) documentation in English ):
Texture2D is a base for other resources. It cannot be used directly.
A better way therefore is to use one of those subclasses of Texture2D that are meant to be used directly, for example an ImageTexture:
alert_dialog.add_theme_icon_override("close", ImageTexture.new())
1 Like