1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 17:19:50 +00:00

Changes to layer re-naming

Layer's LineEdit saves the changes when it loses focus, or when the user presses ESC (or Enter)
This commit is contained in:
OverloadedOrama 2020-03-09 17:17:20 +02:00
parent d64b4edb96
commit 2614ac5b3a
2 changed files with 17 additions and 17 deletions

View file

@ -12,6 +12,7 @@ margin_bottom = 36.0
rect_min_size = Vector2( 212, 36 )
size_flags_horizontal = 0
toggle_mode = true
action_mode = 0
script = ExtResource( 1 )
__meta__ = {
"_edit_horizontal_guides_": [ ],
@ -93,3 +94,4 @@ caret_blink_speed = 0.5
[connection signal="pressed" from="." to="." method="_on_LayerContainer_pressed"]
[connection signal="pressed" from="HBoxContainer/LayerButtons/VisibilityButton" to="." method="_on_VisibilityButton_pressed"]
[connection signal="pressed" from="HBoxContainer/LayerButtons/LockButton" to="." method="_on_LockButton_pressed"]
[connection signal="focus_exited" from="HBoxContainer/LayerName/LineEdit" to="." method="_on_LineEdit_focus_exited"]

View file

@ -28,27 +28,25 @@ func _ready() -> void:
lock_button.texture_hover = load("res://Assets/Graphics/%s Themes/Layers/Unlock_Hover.png" % Global.theme_type)
func _input(event : InputEvent) -> void:
if event.is_action_released("ui_accept") && line_edit.visible && event.scancode != KEY_SPACE:
label.visible = true
line_edit.visible = false
line_edit.editable = false
var new_text : String = line_edit.text
label.text = new_text
Global.layers[i][0] = new_text
if (event.is_action_released("ui_accept") or event.is_action_released("ui_cancel")) and line_edit.visible and event.scancode != KEY_SPACE:
save_layer_name(line_edit.text)
func _on_LayerContainer_pressed() -> void:
pressed = !pressed
var label_initially_visible : bool = label.visible
label.visible = false
line_edit.visible = true
line_edit.editable = true
line_edit.grab_focus()
if label_initially_visible:
label.visible = false
line_edit.visible = true
line_edit.editable = true
line_edit.grab_focus()
else:
label.visible = true
line_edit.visible = false
line_edit.editable = false
func _on_LineEdit_focus_exited() -> void:
save_layer_name(line_edit.text)
func save_layer_name(new_name : String) -> void:
label.visible = true
line_edit.visible = false
line_edit.editable = false
label.text = new_name
Global.layers[i][0] = new_name
func _on_VisibilityButton_pressed() -> void:
if Global.layers[i][1]: