Delete improvements

This commit is contained in:
notdraimdev
2024-11-02 19:13:52 +01:00
parent 833bfc3650
commit 45b758627e
4 changed files with 14 additions and 5 deletions
-1
View File
@@ -18,7 +18,6 @@ func Confiremed():
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
hide()
Show()
func Contact():
print("Contact pressed")
+9 -3
View File
@@ -2,9 +2,10 @@ extends Control
var SongName:String
var CurrentlyPlaying:bool
var idx:int
var songidx:int
@onready var songname: Button = $HBoxContainer/Songname
@onready var dropdown: Button = $HBoxContainer/Dropdown
@onready var popup_menu: PopupMenu = $PopupMenu
signal PlayPressed
@@ -12,7 +13,11 @@ signal DeletePressed
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
songname.text = SongName
popup_menu.index_pressed.connect(popupPressed)
func popupPressed(idx:int):
if idx == 0:
DeletePressed.emit(songidx)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
@@ -20,8 +25,9 @@ func _process(delta: float) -> void:
func _on_songname_pressed() -> void:
PlayPressed.emit(idx)
PlayPressed.emit(songidx)
func _on_dropdown_pressed() -> void:
pass
popup_menu.show()
popup_menu.position = get_global_mouse_position()
+4
View File
@@ -45,5 +45,9 @@ focus_mode = 0
flat = true
alignment = 0
[node name="PopupMenu" type="PopupMenu" parent="."]
item_count = 1
item_0/text = "delete"
[connection signal="pressed" from="HBoxContainer/Dropdown" to="." method="_on_dropdown_pressed"]
[connection signal="pressed" from="HBoxContainer/Songname" to="." method="_on_songname_pressed"]
+1 -1
View File
@@ -24,7 +24,7 @@ func _process(delta: float) -> void:
func add_item(text:String):
var child = SEARCH_ITEM.instantiate()
child.SongName = text.replace(".mp3", "")
child.idx = parent.textSongs.find(text)
child.songidx = parent.textSongs.find(text)
SongsAmount+=1
child.PlayPressed.connect(songSelected)
child.DeletePressed.connect(deletePressed)