godot-resources-as-sheets-p.../addons/resources_spreadsheet_view/main_screen/table_header.gd
2023-01-23 18:06:09 +02:00

34 lines
724 B
GDScript

@tool
extends HBoxContainer
var manager : Control
func set_label(label : String):
$"Button".text = label.capitalize()
$"Button".tooltip_text = label + "\nClick to sort."
func _ready():
$"Button".gui_input.connect(_on_main_gui_input)
$"Button2".get_popup().id_pressed.connect(_on_list_id_pressed)
func _on_main_gui_input(event):
if event is InputEventMouseButton and event.pressed:
var popup = $"Button2".get_popup()
if event.button_index == MOUSE_BUTTON_RIGHT:
popup.visible = !popup.visible
popup.position = get_global_mouse_position()
else:
popup.visible = false
func _on_list_id_pressed(id : int):
if id == 0:
manager.select_column(get_index())
else:
manager.hide_column(get_index())