Screen API ButtonList broken since 21w20a
jackassmc opened this issue ยท 4 comments
21w20a changed buttons to be a "drawable child" of screen, added to a screen by calling addDrawableChild
.
protected <T extends Element & Drawable & Selectable> T addDrawableChild(T drawableElement) {
this.drawables.add((Drawable)drawableElement);
return this.addSelectableChild(drawableElement);
}
protected <T extends Element & Selectable> T addSelectableChild(T child) {
this.children.add(child);
this.selectables.add((Selectable)child);
return child;
}
The port of the screen API to 1.17-pre1 assumes buttons to be a "selectable child", not handling this.drawables
leading to buttons being clickable and functioning but invisible.
While looking into this I found out that the tab order is handled by the order of this.children
, the render order by the order of this.drawables
while this.selectable
has something to do with narration.
@jackassmc wait, where are these? The screen api doesn't add buttons. Where are these buttons added incorrectly?
The screen API allows adding buttons using this:
But it looks like the backing implementation (Fabric API's ButtonList
) does not add them to all needed lists.
There's also an example on how to add buttons that uses the button list:
The testmod also changes a button and adds two new ones:
The notes about list orders are because I'm new to Java and got confused if the proper order of this.children
and this.selectables
is maintained when setting and adding buttons. Could somebody tell me please, it's in here: https://github.com/FabricMC/fabric/blob/b7ab612143d0de808476ea6039740c123c109231/fabric-screen-api-v1/src/main/java/net/fabricmc/fabric/impl/client/screen/ButtonList.java
Edit: I think I found another bug:
children
instead of selectables
).