From 39e62eb8cf3dec2bde7c63d30f1ea8f5ffb51327 Mon Sep 17 00:00:00 2001 From: bleeptrack Date: Tue, 10 Nov 2020 18:34:51 +0100 Subject: [PATCH] New File Popup (no function) --- scenes/file_browser.gd | 6 ++++++ scenes/file_browser.tscn | 4 ++++ scenes/file_browser_item.gd | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scenes/file_browser.gd b/scenes/file_browser.gd index 7502f12..3628854 100644 --- a/scenes/file_browser.gd +++ b/scenes/file_browser.gd @@ -24,6 +24,7 @@ func _ready(): update() _set_mode(mode) _set_title(title) + $PopupMenu.add_item("New file", 1) func _input(event): if event.is_action_pressed("save"): @@ -176,6 +177,11 @@ func _set_title(new_title): title = new_title if title_label: title_label.text = new_title + +func _gui_input(event): + if event is InputEventMouseButton and event.is_pressed() and event.button_index == BUTTON_RIGHT: + $PopupMenu.set_position(get_global_mouse_position()) + $PopupMenu.popup() func very_best_sort(a,b): if a[0] == "." and b[0] != ".": diff --git a/scenes/file_browser.tscn b/scenes/file_browser.tscn index 2c0c196..072e620 100644 --- a/scenes/file_browser.tscn +++ b/scenes/file_browser.tscn @@ -125,5 +125,9 @@ text = "x" __meta__ = { "_edit_use_anchors_": false } + +[node name="PopupMenu" type="PopupMenu" parent="."] +margin_right = 20.0 +margin_bottom = 20.0 [connection signal="pressed" from="Panel/TextEdit/SaveButton" to="." method="save"] [connection signal="pressed" from="Panel/TextEdit/CloseButton" to="." method="close"] diff --git a/scenes/file_browser_item.gd b/scenes/file_browser_item.gd index 8f7456d..ff3910c 100644 --- a/scenes/file_browser_item.gd +++ b/scenes/file_browser_item.gd @@ -15,7 +15,7 @@ onready var status_icon = $VBoxContainer/Control/TextureRect/StatusIcon func _ready(): _set_label(label) _set_status(status) - $PopupMenu.add_item("Delete File", 0) + $PopupMenu.add_item("Delete file", 0) func _set_label(new_label): label = new_label