Skip to content

Instantly share code, notes, and snippets.

@RichardMarks
Created September 5, 2023 21:02
Show Gist options
  • Save RichardMarks/7c02da5a07997f1bf9ee9c0c9a6ef941 to your computer and use it in GitHub Desktop.
Save RichardMarks/7c02da5a07997f1bf9ee9c0c9a6ef941 to your computer and use it in GitHub Desktop.
Godot 4.1.1 Testing opening Window and FileDialog on macOS
  • When exporting an .app for macOS in Debug mode, everything works as-expected.

  • When exporting an .app for macOS in Release mode, the buttons do nothing at all.

Display the source blob
Display the rendered blob
Raw
<svg height="128" width="128" xmlns="http://www.w3.org/2000/svg"><rect x="2" y="2" width="124" height="124" rx="14" fill="#363d52" stroke="#212532" stroke-width="4"/><g transform="scale(.101) translate(122 122)"><g fill="#fff"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 813 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H447l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c3 34 55 34 58 0v-86c-3-34-55-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></g></svg>
extends Control
@onready var btn_1: Button = $CenterContainer/VBoxContainer/Button
@onready var btn_2: Button = $CenterContainer/VBoxContainer/Button2
@onready var window_dlg: Window = $Window
@onready var file_dlg: FileDialog = $FileDialog
func _ready() -> void:
assert(window_dlg.close_requested.connect(Callable(window_dlg, "hide")) == OK)
assert(btn_1.connect("pressed", Callable(window_dlg, "popup_centered")) == OK)
assert(btn_2.connect("pressed", Callable(file_dlg, "popup_centered")) == OK)
[gd_scene load_steps=2 format=3 uid="uid://b6e2fb382for3"]
[ext_resource type="Script" path="res://main.gd" id="1_xgemj"]
[node name="Control" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_xgemj")
[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
layout_mode = 2
theme_override_constants/separation = 24
[node name="Button" type="Button" parent="CenterContainer/VBoxContainer"]
layout_mode = 2
text = "Open test Window"
[node name="Button2" type="Button" parent="CenterContainer/VBoxContainer"]
layout_mode = 2
text = "Open test FileDialog"
[node name="Window" type="Window" parent="."]
title = "Test"
initial_position = 2
size = Vector2i(320, 200)
visible = false
popup_window = true
[node name="CenterContainer" type="CenterContainer" parent="Window"]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="Label" type="Label" parent="Window/CenterContainer"]
layout_mode = 2
text = "Hello World!"
[node name="FileDialog" type="FileDialog" parent="."]
title = "Open a File"
initial_position = 2
size = Vector2i(640, 480)
ok_button_text = "Open"
file_mode = 0
access = 2
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=5
[application]
config/name="Test"
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.1", "Forward Plus")
config/icon="res://icon.svg"
[display]
window/size/viewport_width=1024
window/size/viewport_height=768
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment