Skip to content

Commit

Permalink
Adds an overridden setText function to the CheckBox class.
Browse files Browse the repository at this point in the history
  • Loading branch information
Valkryst committed Aug 29, 2018
1 parent a46354a commit 74540dd
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/com/valkryst/VTerminal/component/CheckBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,25 @@ public void setChecked(final boolean isChecked) {

super.redrawFunction.run();
}

@Override
public void setText(String text) {
if (text == null) {
text = "";
}

for (int x = 0 ; x < tiles.getWidth() ; x++) {
if (x == 0 || x == 1) {
continue;
}

if (x <= text.length()) {
// Because we skip the first two tiles (checkbox & space after it), we have to use -2 to
// compensate.
tiles.getTileAt(x, 0).setCharacter(text.charAt(x - 2));
} else {
tiles.getTileAt(x, 0).setCharacter(' ');
}
}
}
}

0 comments on commit 74540dd

Please sign in to comment.