LibGDX Scene2d: Change width of Table child after it was added - libgdx

I am trying to dynamically change the width of a Scrollpane so its width matches the size of its child element. The Scrollpane is within a Window. The problem is that I don't know the width of the child until after the ScrollPane is added to the Window and .width() is already called.
Is there a way to change the ScrollPane's width after it has been added?
P.S. scrollPane.setWidth() does not work.

Related

How to prevent my wrapper div to move when i resize window?

The content of my wrapper div is moving anytime I resize my browser window's height (or when I open the console log) to keep up with the frame. This cause some elements to overlap with others.
I've tried to add width height min-width and min-height properties to the wrapper without success.
Any suggestion ?

Dash Datatable: Inherit height from parent div

I have a standard design with some controls and a datatable below. I would like the datatable to adjust to the window height. My first thought was to include the table in a div and assign a % height to the div.
However, it seems that the table only responds to vh and not %. Currently I am setting the table height via f"calc(100vh - {margin*2+controls}px)".
Is there any way to adjust the height of the table in proportion to the div it is contained in? Or is there generally a preferred way to achieve this behaviour?

Resize div to contentEditable iFrame using onkeyup

I've got a div that holds a contenteditable iframe. The CSS has height set on auto, I've set it up so on keyup the div resizes to the iframe's scroll height.
I'm able to correctly expand the div based on the content's height, but I am not able to contract the height when removing content from the iframe.
I've tested grabbing the body scrollHeight, Height height, offsetHeight; but they only return the last largest value.
Any ideas?
I was able to solve this by utilizing a constant interval to resize. I'm not too happy with this option, I'd rather keep it as a onkeyup function, but it seems the dom area doesn't resize instantly, it takes X.X seconds for it to realize via contenteditable sections.

give a sprite its children's width

I'm trying to simulate window behavior in AS3, so I have a sprite I named "container" which contains children. One of them is a TextField, others are Sprites.
When I add the textfield in my container I'm glad to see this one's width is re-calculated. So, if my textField width is set to 50px, my container too. So my window simulation is working well.
But, when I add the others sprites, the width of my container does not change, so my window simulation is no more working well... Why is that please ? I can't find no explanation.
Thanks a lot.
This should not be a problem, as the width and height are always calculated based on the children position and sizes. This is taken from the ActionScript documentation:
DisplayObject > width:
Indicates the width of the display object, in pixels. The width is
calculated based on the bounds of the content of the display object.
When you set the width property, the scaleX property is adjusted
accordingly
There must be another problem, so maybe try posting your code, or reducing the problem down to a simple example.

Height of component increasing when adding children

I have a simple flash component that is just a rectangle with a border around it. This component represents my chat box. I then create 20 TextFields that will be overlapped on the component to display text.
The odd thing that is happening is that my components height is originally 200, but with each textfield i add as a child to the component the height data of the component increases by the height of the textfield.
Let me clarify that the height of the object in pixels is not changing, but simply the this.height of the component. I can make a static const that I can use for the original height of the component, but I find this behavior strange.
Could anyone comment on why this is happening?
Thanks!
This is expected behavior. The height property of a parent will include all of its children, same with the width property.
Any graphics drawn inside of this parent will not change, you would have to update this manually by creating a nested clip and adjusting its size.