Package app.ui.widgets
Class WidgetButton
java.lang.Object
app.ui.widgets.Widget
app.ui.widgets.WidgetButton
- All Implemented Interfaces:
IDrawable,ISelectable,ITextInput
WidgetButton is a UI widget that represents a button. It extends the Widget class
and implements IClickable, ITextInput, and ISelectable interfaces.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionWidgetButton(int x, int y, int len, String text) Constructs a WidgetButton with specified position, length, and text.WidgetButton(int x, int y, int len, String text, TEXT_ALIGNMENT textAlignment) Constructs a WidgetButton with specified position, length, text, and text alignment. -
Method Summary
Modifier and TypeMethodDescriptionvoidClears the pressed status of the button.voiddraw(char[][] buffer, com.googlecode.lanterna.TextColor[][] printColor, com.googlecode.lanterna.TextColor[][] backColor) Draws the text displayed on the button.voiddrawSelection(char[][] buffer, com.googlecode.lanterna.TextColor[][] printColor, com.googlecode.lanterna.TextColor[][] backColor) Returns the text displayed on the button.booleanReturns the pressed status of the button.voidkeyStroke(com.googlecode.lanterna.input.KeyStroke keyStroke) Handles a keystroke input and changes the pressed status if the key is Enter.voidselect()Marks the button as selected.voidunselect()Marks the button as unselected.Methods inherited from class app.ui.widgets.Widget
drawText, getLen, getSelected, getSkipSelection, getText, getWidgetID, getX, getY, isHide, setHide, setSkipSelection, setText, setWidgetID
-
Constructor Details
-
WidgetButton
Constructs a WidgetButton with specified position, length, and text. The button is initially not pressed.- Parameters:
x- The x-coordinate of the button.y- The y-coordinate of the button.len- The length of the button.text- The text displayed on the button.
-
WidgetButton
Constructs a WidgetButton with specified position, length, text, and text alignment. The button is initially not pressed.- Parameters:
x- The x-coordinate of the button.y- The y-coordinate of the button.len- The length of the button.text- The text displayed on the button.textAlignment- The text alignment of the button.
-
-
Method Details
-
select
public void select()Marks the button as selected.- Specified by:
selectin interfaceISelectable
-
unselect
public void unselect()Marks the button as unselected.- Specified by:
unselectin interfaceISelectable
-
getPressed
public boolean getPressed()Returns the pressed status of the button.- Returns:
- true if the button is pressed, false otherwise.
-
clearPressed
public void clearPressed()Clears the pressed status of the button. -
drawSelection
public void drawSelection(char[][] buffer, com.googlecode.lanterna.TextColor[][] printColor, com.googlecode.lanterna.TextColor[][] backColor) Returns the text displayed on the button.- Specified by:
drawSelectionin interfaceISelectable- Parameters:
buffer- The buffer to draw the text on.printColor- The print color of the text.backColor- The background color of the text.
-
draw
public void draw(char[][] buffer, com.googlecode.lanterna.TextColor[][] printColor, com.googlecode.lanterna.TextColor[][] backColor) Draws the text displayed on the button. -
keyStroke
public void keyStroke(com.googlecode.lanterna.input.KeyStroke keyStroke) Handles a keystroke input and changes the pressed status if the key is Enter.- Specified by:
keyStrokein interfaceITextInput- Parameters:
keyStroke- The KeyStroke input to handle.
-