Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ListEntryWidget extends AbstractWidget implements ContainerEventHan

private final String optionNameString;

private GuiEventListener focused;
@Nullable private GuiEventListener focused;
private boolean dragging;

public ListEntryWidget(YACLScreen screen, ListOptionEntry<?> listOptionEntry, AbstractWidget entryWidget) {
Expand Down Expand Up @@ -87,7 +87,7 @@ protected void updateButtonStates() {

@Override
public void unfocus() {
entryWidget.unfocus();
setFocused(null);
}

@Override
Expand Down Expand Up @@ -123,9 +123,20 @@ public GuiEventListener getFocused() {

@Override
public void setFocused(@Nullable GuiEventListener focused) {
this.focused = focused;
if (this.focused != focused) {
if (this.focused != null)
this.focused.setFocused(false);

if (focused != null)
focused.setFocused(true);

this.focused = focused;
}
}

@Override
public void setFocused(boolean focused) {}

//? if >=1.21.11 {
@Override
public boolean mouseClicked(net.minecraft.client.input.MouseButtonEvent mouseButtonEvent, boolean doubleClick) {
Expand Down
2 changes: 2 additions & 0 deletions src/testmod/java/dev/isxander/yacl3/test/ConfigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class ConfigTest {
@SerialEntry
public ChatFormatting formattingOption = ChatFormatting.RED;

@SerialEntry
public List<Color> colorList = List.of(Color.red, Color.green, Color.blue);
@SerialEntry
public List<String> stringList = List.of("This is quite cool.", "You can add multiple items!", "And it is integrated so well into Option groups!");
@SerialEntry
Expand Down
10 changes: 10 additions & 0 deletions src/testmod/java/dev/isxander/yacl3/test/GuiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@ private static Screen getFullTestSuite(Screen parent) {
.build())
.category(ConfigCategory.createBuilder()
.name(Component.literal("List Test"))
.group(ListOption.<Color>createBuilder()
.name(Component.literal("Color List"))
.binding(
defaults.colorList,
() -> config.colorList,
val -> config.colorList = val
)
.controller(ColorControllerBuilder::create)
.initial(Color.white)
.build())
.group(ListOption.<String>createBuilder()
.name(Component.literal("String List"))
.binding(
Expand Down