I have a scrollpanel test headers in it. Through debug, I see that the panel itself is there, but the content is not displayed in it, although it seems to be. Maybe someone knows how this is possible? The panel itself adjusts to the size of the table, but the table itself, with the content inside, is not visible.
-
Have you tried calling `pack()` in table nested in the scroll pane? E.g. after that items loop. I also suggest trying to customize the table outside the scroll pane first to make sure that it renders as you expect it too, and then to put it in the scroll pane. As a side note, you can set a `Skin` instance globally via `Scene2DSkin.defaultSkin`, so you can avoid passing it to each widget method. – Czyzby Jul 30 '20 at 19:42
-
@Czyzby, Outside the scroll, I collected the table there, it works fine, pack () did it too, just like layuot (), none of this helped, I see that the scroll adjusts its size to the size of the content, but it is not visible. I tried skins in different ways, it seems to me that if something was wrong with them, then at least through debug you could see the outline of the internal table. – Евгений Латынин Jul 31 '20 at 07:01
-
Could you upload a minimal example reproducing the issue (e.g. to GitHub)? You can use one of the default skins if you don't want to publish your assets. If you could link that example in an issue in the official libktx/ktx repository, I could go through the code and we can move the discussion there. – Czyzby Jul 31 '20 at 08:18
-
@Czyzby , well, just not now, there is a blockage at work, I think in 6-7 hours, when I am at home, I will create and throw you a link. – Евгений Латынин Jul 31 '20 at 09:07
-
@Czyzby I cleaned up the project if possible, and uploaded this test version to github, here in this [window] (https://github.com/LatyninEugene/test-libktx-scroll/blob/master/core/src/main/kotlin/ru/latynin/ltd/screens/InventoryWindow.kt) and there is that scroll, now it is commented out and instead of it there is a table. I added //Scroll and //Table comments to understand what needs to be commented out and what to uncomment in order to switch between them. – Евгений Латынин Jul 31 '20 at 11:26
-
Something I did not understand why the link was not converted here. – Евгений Латынин Jul 31 '20 at 11:29
-
Done. You can delete the repository if you'd prefer to keep the code private. Very nice GUI, by the way! – Czyzby Jul 31 '20 at 16:43
1 Answers
I found the root cause of the issue - you incorrectly added the actors to the stage, which resulted in Window
's and ScrollPane
's Stage
to be null
. You have to change this line in GameManager
:
screen.rootStage.actors.add(inventoryWindow.window)
To this line:
screen.rootStage.addActor(inventoryWindow.window)
While your approach did add the actors to the Stage
, they were not added to the root Group
and their Stage
variable was not set, which resulted in weird bugs like this one. Always prefer to use the public API methods instead of accessing the class variables directly.
About pinpointing the issue: if you look into the ScrollPane
rendering code, you'll notice that it only renders it children if clipBegin
returns true. If you dig deeper, clipBegin
has this particular check that prevented the children from being drawn: if (stage == null) return false;
. Basically, you cannot use a ScrollPane
without a Stage
.

- 2,999
- 1
- 22
- 40
-
Yes it helped, thanks a lot. I will not be able to delete the repository if it comes to this question. I will also note that there was a problem with deletion, it was necessary for example to delete the object `inventoryWindow.window.remove()`, and not from its list. – Евгений Латынин Jul 31 '20 at 19:37