I am making a mockup desktop for a sandbox recreation. I’ve a script, during which I outlined a ObjContainer
class that extends the Management
class (the Container
class has some behaviours that I do not need). I hooked up stated script to the node “ObjContainer”. After I verify it within the Native tab of the Scene Tree, it reveals that the “ObjContainer” node is of sort ObjContainer
as meant, proven in image 1. After I ran the scene, I observed that the “ObjContainer” has now instantly become a Management
node, proven in image 2.*
* Edit: All nodes with {custom} class appear to have this behaviour. The distant tree at all times present native node sorts that I lengthen from. The true problem is as follows:
Calling ObjContainer
-exclusive capabilities brings up an error that claims:
Invalid name. Nonexistent perform ‘request_select’ in base ‘Management (ObjContainer)’.
Why does it try this? Each single custom-class-exclusive name labored completely advantageous beforehand. I even commented out the request_select()
line and it ran easily. What’s up with my ObjContainer
?
The next is the script from the node calling the perform:
class_name FileObject
extends MarginContainer
@onready var texture_rect:TextureRect = $VBoxContainer/Icon
@onready var label:Label = $VBoxContainer/Identify
@onready var obj_container:ObjContainer = ObjContainer.new()
@onready var desktop = $/root/Desktop
@export var file_icon:Texture2D = preload("res://xeth_os/icons/assortment.png")
@export var file_name:String = ""
@export var target_scene:PackedScene = null
var intended_size:Vector2 = Vector2(74, 126)
# Customized constructor.
func init(i:Texture2D, n:String, t:PackedScene) -> void:
file_icon = i
file_name = n
target_scene = t
# Known as when the node enters the scene tree for the primary time.
func _ready() -> void:
texture_rect.texture = file_icon
label.textual content = file_name
if get_parent() is ObjContainer:
obj_container = get_parent()
# Known as each body. 'delta' is the elapsed time because the earlier body.
func _process(delta: float) -> void:
cross
func choose() -> void:
modulate = Coloration.BLUE
label.text_overrun_behavior = TextServer.OVERRUN_NO_TRIMMING
func unselect() -> void:
modulate = Coloration.WHITE
label.text_overrun_behavior = TextServer.OVERRUN_TRIM_ELLIPSIS
func open_file() -> void:
var t:PackedScene = target_scene
var w:XeWindow = preload("res://xeth_os/elements/window/xethos_window.tscn").instantiate()
w.init(t)
desktop.add_child(w)
func _on_gui_input(occasion: InputEvent) -> void:
if occasion is InputEventMouseButton:
if occasion.pressed:
obj_container.request_select(self)
if occasion.button_mask == 1 and occasion.double_click:
open_file()
if occasion is InputEventMouseMotion :
if occasion.button_mask == 1: #left mouse buton is pressed
global_position += occasion.relative
global_position = global_position.clamp(desktop.top_bar_offset, get_viewport_rect().measurement - intended_size)
And the script from the ObjContainer class:
class_name ObjContainer
extends Management
func request_selection(f:FileObject) -> void:
var l:Array[FileObject] = get_file_objects()
l.erase(f)
for i in l:
i.unselect()
f.choose()
func get_file_objects() -> Array[FileObject]:
var c:Array[Node] = get_children()
var f:Array[FileObject] = []
for i in c:
if i is FileObject:
f.push_front(i as FileObject)
return f
func _on_gui_input(occasion: InputEvent) -> void:
if occasion is InputEventMouseButton:
for i in get_file_objects():
i.unselect()