From 35b0f811f23f029110373798b19d9d0895d907f0 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sun, 5 Jan 2025 16:54:36 +0100 Subject: next commit --- ui/chat_window.gd | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'ui/chat_window.gd') diff --git a/ui/chat_window.gd b/ui/chat_window.gd index c88a3ee..7841d57 100644 --- a/ui/chat_window.gd +++ b/ui/chat_window.gd @@ -3,6 +3,9 @@ extends PanelContainer @export var player_color: Color = Color8(255, 255, 255) +var is_dragging := false +var drag_anchor := Vector2.ZERO + func _ready() -> void: # clear test label @@ -57,3 +60,17 @@ func _on_broadcast_formatted_message_packet_received(packet: BroadcastFormattedM format.size = packet.font_size add_message(packet.message, format) + + +func _process(_delta: float) -> void: + if is_dragging: + global_position += get_global_mouse_position() - drag_anchor + drag_anchor = get_global_mouse_position() + + +func _on_handle_gui_input(event: InputEvent) -> void: + if event.is_action_pressed("primary_click"): + is_dragging = true + drag_anchor = get_global_mouse_position() + elif event.is_action_released("primary_click"): + is_dragging = false -- cgit v1.2.3