#Can you manually offset the position of a control inside a container?

90 messages · Page 1 of 1 (latest)

patent dock
#

I'm trying to make the dialogue choices ("Nope" and "Definitely not" in the first pic) slide up using a tween, but they're all children of an HBoxContainer (the node layout is in the second pic). Is there some way to tell godot to offset the position of the text by a certain amount? I want the text to still be a part of the hbox and not have to manually set X/Y coordinates all the time, but I also still want control over their Y position relative to their "normal" container-based position. That way I can tween the offset from something like 200 to 0 to make the text slide up from the bottom of the screen.

This could just be an "X Y" problem, so if there's some easier way to do this, that'd prob be just as good, as long as it doesn't involve expanding the parent container (I don't want the white rect outline to change at all, the first pic is only like that because of a bug).

Thanks.

patent dock
#

huh so if i use control nodes and make the text a child of the control, it can move freely since it's not a child of a container... but then the control's width is 0 instead of the exact width of the text label... which sucks because i need the width to be enough to fit the text (the labels have "fit content" enabled)

#

i tried margin containers too but "clip contents" just straight up doesn't work with those, like the parent box will expand to fit the whole margin as well and make the dialog box super tall just so the margin will be visible above the text... when i want the text to be clipped off and just have the margin visible

#

i guess a really hacky solution would be to set the control's width to match the text box's width any time i update the text, but there's gotta be a better way than that crap lol

#

and the reason the width matters is because...

patent dock
#

this is what margin containers do btw... i've been messing with this for like an hour and i'm still confused on what the actual problem is

mossy wyvern
#

Containers completely control their children positions, if you want a custom position you need a custom container

patent dock
#

like extend the container class?

mossy wyvern
#

Yes

patent dock
#

will that let me make the text be clipped off if out of bounds?

#

cuz the other container types still show the text even if it's set to clip contents

mossy wyvern
#

That's weird let me test it

#

A container should expand to fit all its children, so it will never use clip contents

patent dock
#

oh

mossy wyvern
#

unless it's scrollcontainer

patent dock
#

how can i make that not happen?

#

without showing a scroll bar

mossy wyvern
#

You could not use a container

#

Or make a custom one

patent dock
mossy wyvern
#

I think you would just check the clip_contents variable

#

Then it will do it by itself

patent dock
#

wait so why make a custom container class?

mossy wyvern
#

You want to move the children, right?

patent dock
mossy wyvern
#

Yeah you wanted to tween the dialogue choices

patent dock
#

yeah

#

sorry got confused cuz the containers that hold the text labels are also inside a container inside other containers etc

mossy wyvern
#

lol

patent dock
# mossy wyvern lol

i haven't actually written anything in the script yet but now i'm having an issue of the container not fitting the text horizontally...

#

sorry i'm just starting to realize what i really wanted to make 💀

#

so

#

the whole "clip contents" part i only want to apply to height

#

but i want it to still fit the width to whatever it needs to

#

so i kinda can't just tell it to clip contents...

mossy wyvern
#

Okay, you can code the container to fit the width

patent dock
#

is there some reference script for how the other containers work that i could use?

#

i just want it to do the same expand thing but only for width

#

or should i just extend another container type and just override some method to make it do this?

mossy wyvern
#

Containers don't have methods like that you can override

patent dock
#

:/

#

how does it even work?

mossy wyvern
patent dock
#

oop

mossy wyvern
#

But it's not very informative

#

You kinda have to figure things out yourself or ask in discord lol

patent dock
#

is the page still up to date enough for godot 4?

mossy wyvern
#

Yes

patent dock
#

if not specifically 4.2

#

alr great

#

at the bottom of the page

#

ty

#

.........................

#

;-;

#

wait i can't even launch the editor anymore what

mossy wyvern
#

oh no

#

oh NO

patent dock
#

?

#

the stack trace is showing my gdextension library so it might just be something i didn't update in my code

mossy wyvern
#

oh okay

patent dock
#

but then at the bottom it says godot again so idk lol

frosty wasp
#

It makes sense though that it would say GODOT at both sides. It is coordinating everything, AND converting your script to something usable for the code.

patent dock
#

true

#

i'm like 10% focused on this rn cuz i have to go somewhere in a bit 💀

#

i changed something for getting the nodes to cast to Control earlier so i prob have to change that or smt

#

i pushed that to a different branch and just reset back to the last commit before all my other changes, gonna try just redoing the custom script part without any other stuff that might cause issues

#

so either i messed something up while writing the script OR my uncommitted changes broke something (probably) lol

#

YEAH THAT'S WEIRD

#

AS SOON AS I ATTACH A SCRIPT IT STOPS WORKING

#

LOL

#

@mossy wyvern do you think this is an issue with the gdextension library or something else?

mossy wyvern
#

I don't know much about gdextension

patent dock
#

i have no idea what to look for now

#

oof

patent dock
#

FWIW it also says BoxContainer doesn't exist, and if i remove the extends line entirely it says RefCounted doesn't exist, i assume no extends line = extends RefCounted by default...

#

and the script can exist in the project but not be attached to the container and it doesn't crash

patent dock
#

update: i wrote the custom class in a gdextension library with rust and somehow there aren't any errors

#

what the actual hell

#

i still have no idea what's wrong kekw

frosty wasp
#

Can you show the whole stack trace?

patent dock
#

for the gdscript version?

#

@frosty wasp

frosty wasp
#

I was expecting a few more hints in the stack trace, but it looks like the only thing is that it couldn't find a few things it needed.

Do you know what information is supposed to be in templates_search_path? I find it interesting that it's looking for an editor script, then failing to find a Godot feature before failing out on a template hash map