Add global show/hide toggle for the Shutter window

Reads a new ToggleShutterInputActionLineEdit setting and checks it in
_process() with Input.is_action_just_pressed() instead of _input(),
since the Shutter is its own native Window: its _input() only fires
while it has OS focus, and stops entirely once hidden. Input's action
state is global to the process, so this lets the configured key show
the Shutter again from the main Play window.
This commit is contained in:
stilobique committed 2026-11-05 11:46:27 +01:00
1 parent c4ee699d49
commit 6bbf5d4a8d
1 file changed
+16
+16
View File
@@ -13,6 +13,7 @@ signal image_captured(image: Image)
signal burst_ended signal burst_ended
var _input_action: String var _input_action: String
var _toggle_shutter_action: String
func _ready() -> void: func _ready() -> void:
@@ -25,14 +26,29 @@ func _ready() -> void:
if only_run_in_editor and not OS.has_feature("editor"): if only_run_in_editor and not OS.has_feature("editor"):
set_process_input(false) set_process_input(false)
set_process(false)
hide() hide()
return return
_input_action = _local_data.settings.load_value("misc", "InputActionLineEdit", "") _input_action = _local_data.settings.load_value("misc", "InputActionLineEdit", "")
_toggle_shutter_action = _local_data.settings.load_value("misc", "ToggleShutterInputActionLineEdit", "")
%ShutterButton.pressed.connect(take_burst) %ShutterButton.pressed.connect(take_burst)
close_requested.connect(_on_close_requested) close_requested.connect(_on_close_requested)
## Checked every frame (not via _input) because the shutter is its own native
## Window: once hidden, it stops receiving OS input entirely, and its _input()
## only ever fires while it has OS focus anyway. Input.is_action_just_pressed
## reflects global key state for the whole process, so this lets the toggle be
## pressed from the main Play window even while the shutter is hidden.
func _process(_delta: float) -> void:
if _toggle_shutter_action.is_empty() or not InputMap.has_action(_toggle_shutter_action):
return
if Input.is_action_just_pressed(_toggle_shutter_action):
visible = not visible
_local_data.settings.save("misc", "ShowShutterCheckBox", visible)
func _on_close_requested() -> void: func _on_close_requested() -> void:
hide() hide()