Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ListField to create 2D list fields #282

Merged
merged 18 commits into from Aug 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/de/gurkenlabs/litiengine/gui/DropdownListField.java
Expand Up @@ -63,23 +63,23 @@ public Spritesheet getEntrySprite() {
}

public List<ImageComponent> getListEntries() {
return this.getContentList().getListEntries();
return this.getContentList().getListEntry(0);
}

public int getNumberOfShownElements() {
return this.numberOfShownElements;
}

public int getSelectedIndex() {
return this.getContentList().getSelection();
return this.getContentList().getSelectionRow();
}

public Object getSelectedObject() {
if (this.getContentArray().length == 0) {
return null;
}

return this.getContentArray()[this.getContentList().getSelection()];
return this.getContentArray()[this.getContentList().getSelectionRow()];
}

public boolean isArrowKeyNavigation() {
Expand Down Expand Up @@ -113,7 +113,7 @@ public void prepare() {
this.getContentList().suspend();

if (!this.getListEntries().isEmpty()) {
this.chosenElementComponent.setText(this.getListEntries().get(this.getSelectedIndex()).getText());
this.chosenElementComponent.setText(this.getListEntries().get(0).getText());
}

this.dropDownButton.onClicked(e -> this.toggleDropDown());
Expand Down Expand Up @@ -146,7 +146,7 @@ public void setSelection(final int selectionIndex) {
return;
}

this.getContentList().setSelection(selectionIndex);
this.getContentList().setSelection(0, selectionIndex);
}

public void setSelection(final Object selectedObject) {
Expand Down Expand Up @@ -182,24 +182,24 @@ private void prepareInput() {
if (this.isSuspended() || !this.isVisible() || !this.isArrowKeyNavigation() || !this.getChosenElementComponent().isHovered()) {
return;
}
this.getContentList().setSelection(this.getSelectedIndex() - 1);
this.getContentList().setSelection(0, this.getSelectedIndex() - 1);
});

Input.keyboard().onKeyTyped(KeyEvent.VK_DOWN, e -> {
if (this.isSuspended() || !this.isVisible() || !this.isArrowKeyNavigation() || !this.getChosenElementComponent().isHovered()) {
return;
}
this.getContentList().setSelection(this.getSelectedIndex() + 1);
this.getContentList().setSelection(0, this.getSelectedIndex() + 1);
});

this.onMouseWheelScrolled(e -> {
if (this.isSuspended() || !this.isVisible() || !this.getChosenElementComponent().isHovered()) {
return;
}
if (e.getEvent().getWheelRotation() < 0) {
this.getContentList().setSelection(this.getSelectedIndex() - 1);
this.getContentList().setSelection(0, this.getSelectedIndex() - 1);
} else {
this.getContentList().setSelection(this.getSelectedIndex() + 1);
this.getContentList().setSelection(0, this.getSelectedIndex() + 1);
}
return;
});
Expand Down