feat: collection context menu

This commit is contained in:
LunarAkai 2025-07-01 12:48:34 +02:00
commit a47a818f8b
5 changed files with 38 additions and 4 deletions

View file

@ -2,6 +2,7 @@ class_name ContainerSelectionButton extends MarginContainer
@export var button: Button
@export var container_box: ContainerBox
@export var popup_menu: PopupMenu
var button_index: int
@ -19,3 +20,15 @@ func _enter_tree() -> void:
## Buttons are 1-indexed, while [member UIManager.panel_array] is 0-index
func _on_button_pressed() -> void:
SignalBus.on_panel_requested.emit(button_index-1)
func _input(event: InputEvent) -> void:
if get_global_rect().has_point(get_global_mouse_position()):
if event.is_action_released("right_click"):
popup_menu.popup_on_parent(
Rect2(
button.get_global_rect().position.x,
button.get_global_rect().position.y+20,
button.get_global_rect().size.x,
button.get_global_rect().size.y)
)