* Made sure console is always scrolled to bottom, if you scrolled to bottom. so if new text comes it still stays at bottom.

This commit is contained in:
2025-10-09 01:25:47 +02:00
parent ff083769d8
commit 7c3ed03d65
2 changed files with 22 additions and 1 deletions

View File

@@ -1,8 +1,12 @@
extends Node2D
var auto_scroll_enabled := true
@onready var lbl_text = $CanvasLayer/ColorRectBG/VBoxContainer/ScrollContainer/LabelText
@onready var sb = null
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
sb = lbl_text.get_v_scroll_bar()
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -14,6 +18,7 @@ func _process(delta: float) -> void:
#tween console to -y 240
target_y = -$CanvasLayer/ColorRectBG.size.y
tween.tween_property($CanvasLayer/ColorRectBG, "position:y", target_y, 0.13).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
pass
func isOpen() -> bool:
@@ -26,4 +31,18 @@ func print(...args) -> void:
print(line)
# append to your console label
$CanvasLayer/ColorRectBG/VBoxContainer/ScrollContainer/LabelText.text += "\n" + line
lbl_text.text += "\n" + line
if auto_scroll_enabled:
lbl_text.scroll_to_line(lbl_text.get_line_count() - 1)
func _on_label_text_gui_input(event: InputEvent) -> void:
if event is InputEventMouseButton and event.button_index in [MOUSE_BUTTON_WHEEL_UP, MOUSE_BUTTON_WHEEL_DOWN]:
auto_scroll_enabled = sb.value + sb.page >= sb.max_value - 10.0
elif event is InputEventMouseButton and event.is_pressed():
auto_scroll_enabled = sb.value + sb.page >= sb.max_value - 10.0
elif event is InputEventMouseMotion and (event.button_mask & MOUSE_BUTTON_LEFT):
# Only update when dragging with left mouse button
auto_scroll_enabled = sb.value + sb.page >= sb.max_value - 10.0
pass # Replace with function body.

View File

@@ -50,3 +50,5 @@ layout_mode = 2
size_flags_horizontal = 3
caret_blink = true
caret_force_displayed = true
[connection signal="gui_input" from="CanvasLayer/ColorRectBG/VBoxContainer/ScrollContainer/LabelText" to="." method="_on_label_text_gui_input"]