public class UIButton extends UIComponent<UIButton>
Modifier and Type | Class and Description |
---|---|
static class |
UIButton.ClickEvent
Event fired when a
UIButton is clicked. |
ITransformable.Alpha, ITransformable.Brightness, ITransformable.Color, ITransformable.Position<T>, ITransformable.Rotate, ITransformable.Scale, ITransformable.Size<T>, ITransformable.Translate
Modifier and Type | Field and Description |
---|---|
protected boolean |
autoSize
Whether the size of this
UIButton is automatically calculated based on its contents. |
protected int |
bgColor
The background color of this
UIButton . |
protected int |
hoverTextColor
The hovered text color of this
UIButton . |
protected GuiIcon |
iconDisabled |
protected GuiIcon |
iconHovered |
protected GuiIcon |
iconPressed |
protected UIImage |
image
Image used for this
UIButton . |
protected boolean |
isPressed
Whether this
UIButton is currently being pressed. |
protected int |
offsetX
Offset for the contents
|
protected int |
offsetY
Offset for the contents
|
protected java.lang.String |
text
Text used for this
UIButton . |
protected int |
textColor
The text color of this
UIButton . |
protected boolean |
textShadow
Whether to use shadow for the text of this
UIButton . |
Constructor and Description |
---|
UIButton(MalisisGui gui)
Instantiates a new
UIButton . |
UIButton(MalisisGui gui,
java.lang.String text)
Instantiates a new
UIButton . |
UIButton(MalisisGui gui,
UIImage image)
Instantiates a new
UIButton . |
Modifier and Type | Method and Description |
---|---|
void |
drawBackground(GuiRenderer renderer,
int mouseX,
int mouseY,
float partialTick)
Called first when drawing this
UIComponent . |
void |
drawForeground(GuiRenderer renderer,
int mouseX,
int mouseY,
float partialTick)
Called last when drawing this
UIComponent . |
int |
getBgColor()
Gets the background color of this
UIButton . |
int |
getHoverTextColor()
Gets the hovered text color of this
UIButton . |
UIImage |
getImage()
|
int |
getOffsetX()
Gets the text offset of this
UIButton . |
int |
getOffsetY()
Gets the text offset of this
UIButton . |
java.lang.String |
getPropertyString()
Gets the property string.
|
java.lang.String |
getText()
Gets the text of this
UIButton . |
int |
getTextColor()
Gets the text color of this
UIButton . |
boolean |
isAutoSize()
Checks if is width is automatically calculated.
|
boolean |
isTextShadow()
Whether the text of this
UIButton is drawn with shadow. |
boolean |
onButtonPress(int x,
int y,
MouseButton button) |
boolean |
onButtonRelease(int x,
int y,
MouseButton button) |
boolean |
onClick(int x,
int y) |
UIButton |
setAutoSize(boolean autoSize)
Sets whether the size of this
UIButton should be calculated automatically. |
UIButton |
setBgColor(int bgColor)
Sets the background color of this
UIButton . |
UIButton |
setHoverTextColor(int hoverTextColor)
Sets the hover text color of this
UIButton . |
UIButton |
setImage(UIImage image)
|
UIButton |
setOffset(int x,
int y)
Sets the text offset of this
UIButton . |
UIButton |
setOptions(int textColor,
int hoverTextColor,
int bgColor,
boolean textShadow)
Sets the options for this
UIButton . |
UIButton |
setSize(int width)
Sets the width of this
UIButton with a default height of 20px. |
UIButton |
setSize(int width,
int height)
Sets the size of this
UIButton . |
UIButton |
setText(java.lang.String text)
Sets the text of this
UIButton . |
UIButton |
setTextColor(int textColor)
Sets the text color of this
UIButton . |
UIButton |
setTextShadow(boolean textShadow)
Sets the text shadow for this
UIButton . |
addControlComponent, componentX, componentY, draw, fireEvent, getAlpha, getAnchor, getComponentAt, getGui, getHeight, getName, getParent, getRawHeight, getRawWidth, getTooltip, getWidth, getX, getY, getZIndex, isDisabled, isFocused, isHovered, isInsideBounds, isRelativeHeight, isRelativeWidth, isVisible, onAddedToScreen, onDoubleClick, onDrag, onKeyTyped, onMouseMove, onRightClick, onScrollWheel, parentX, parentY, register, relativeX, relativeY, removeAllControlComponents, removeControlComponent, screenX, screenY, setAlpha, setAnchor, setDisabled, setFocused, setHovered, setName, setParent, setPosition, setPosition, setTooltip, setTooltip, setVisible, setZIndex, toString, unregister
protected GuiIcon iconHovered
protected GuiIcon iconDisabled
protected GuiIcon iconPressed
protected java.lang.String text
protected UIImage image
protected boolean autoSize
UIButton
is automatically calculated based on its contents.protected boolean isPressed
UIButton
is currently being pressed.protected int bgColor
UIButton
.protected int textColor
UIButton
.protected int hoverTextColor
UIButton
.protected boolean textShadow
UIButton
.protected int offsetX
protected int offsetY
public UIButton(MalisisGui gui)
UIButton
.gui
- the guipublic UIButton(MalisisGui gui, java.lang.String text)
UIButton
.gui
- the guitext
- the textpublic UIButton(MalisisGui gui, UIImage image)
UIButton
.gui
- the guiimage
- the imagepublic java.lang.String getText()
UIButton
.UIButton
.public UIButton setText(java.lang.String text)
UIButton
.text
- the textUIButton
public UIImage getImage()
public UIButton setImage(UIImage image)
UIImage
for this UIButton
. If a width of 0 was previously set, it will be recalculated for this image.image
- the imageUIButton
public UIButton setSize(int width)
UIButton
with a default height of 20px.width
- the widthUIButton
public UIButton setSize(int width, int height)
UIButton
.setSize
in interface ITransformable.Size<UIButton>
setSize
in class UIComponent<UIButton>
width
- the widthheight
- the heightUIButton
public boolean isAutoSize()
UIButton
cannot be smaller that its contents.public UIButton setAutoSize(boolean autoSize)
UIButton
should be calculated automatically.autoSize
- the autoSize to setpublic int getBgColor()
UIButton
.public UIButton setBgColor(int bgColor)
UIButton
.bgColor
- the bg colorpublic int getTextColor()
UIButton
.public UIButton setTextColor(int textColor)
UIButton
.textColor
- the text colorpublic int getHoverTextColor()
UIButton
.public UIButton setHoverTextColor(int hoverTextColor)
UIButton
.hoverTextColor
- the hover text colorpublic boolean isTextShadow()
UIButton
is drawn with shadow.public UIButton setTextShadow(boolean textShadow)
UIButton
.textShadow
- the text shadowpublic int getOffsetX()
UIButton
.public int getOffsetY()
UIButton
.public UIButton setOffset(int x, int y)
UIButton
.x
- the xy
- the ypublic UIButton setOptions(int textColor, int hoverTextColor, int bgColor, boolean textShadow)
UIButton
.textColor
- the text colorhoverTextColor
- the hover text colorbgColor
- the bg colortextShadow
- the text shadowpublic boolean onClick(int x, int y)
onClick
in class UIComponent<UIButton>
public void drawBackground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick)
UIComponent
UIComponent
.drawBackground
in class UIComponent<UIButton>
renderer
- the renderermouseX
- the mouse xmouseY
- the mouse ypartialTick
- the partial tickpublic void drawForeground(GuiRenderer renderer, int mouseX, int mouseY, float partialTick)
UIComponent
UIComponent
.drawForeground
in class UIComponent<UIButton>
renderer
- the renderermouseX
- the mouse xmouseY
- the mouse ypartialTick
- the partial tickpublic boolean onButtonPress(int x, int y, MouseButton button)
onButtonPress
in class UIComponent<UIButton>
public boolean onButtonRelease(int x, int y, MouseButton button)
onButtonRelease
in class UIComponent<UIButton>
public java.lang.String getPropertyString()
UIComponent
getPropertyString
in class UIComponent<UIButton>