diff --git a/loading_failed_screen.gd b/loading_failed_screen.gd index d043ef9..c110f25 100644 --- a/loading_failed_screen.gd +++ b/loading_failed_screen.gd @@ -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") diff --git a/search_item.gd b/search_item.gd index ba8c793..7b9d5ee 100644 --- a/search_item.gd +++ b/search_item.gd @@ -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() diff --git a/search_item.tscn b/search_item.tscn index 147032d..e5610da 100644 --- a/search_item.tscn +++ b/search_item.tscn @@ -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"] diff --git a/search_results.gd b/search_results.gd index defce9a..bf79901 100644 --- a/search_results.gd +++ b/search_results.gd @@ -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)