Class WText
java.lang.Object
io.github.cottonmc.cotton.gui.widget.WWidget
io.github.cottonmc.cotton.gui.widget.WText
A multiline label widget.
- Since:
- 1.8.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected intprotected HorizontalAlignmentprotected net.minecraft.text.Textprotected VerticalAlignment -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNarrations(net.minecraft.client.gui.screen.narration.NarrationMessageBuilder builder) Adds the narrations of this widget to a narration builder.booleanChecks whether this widget can be resized usingWWidget.setSize(int, int).Disables separate dark mode coloring by copying the dark color to be the light color.intgetColor()Gets the light mode color of this label.intGets the dark mode color of this label.Gets the horizontal alignment of this text widget.net.minecraft.text.TextgetText()Gets the text of this label.@Nullable net.minecraft.text.StylegetTextStyleAt(int x, int y) Gets the text style at the specific widget-space coordinates.Gets the vertical alignment of this text widget.onClick(int x, int y, int button) Notifies this widget that the mouse has been pressed and released, both while inside its bounds.voidpaint(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int mouseX, int mouseY) Paints this widget.setColor(int color) Sets the light mode color of this label.setColor(int color, int darkmodeColor) Sets the light and dark mode colors of this label.setDarkmodeColor(int darkmodeColor) Sets the dark mode color of this label.setHorizontalAlignment(HorizontalAlignment horizontalAlignment) Sets the horizontal alignment of this text widget.voidsetSize(int x, int y) Sets the size of this widget.setText(net.minecraft.text.Text text) Sets the text of this label.setVerticalAlignment(VerticalAlignment verticalAlignment) Sets the vertical alignment of this text widget.Methods inherited from class io.github.cottonmc.cotton.gui.widget.WWidget
addPainters, addTooltip, canFocus, canHover, cycleFocus, getAbsoluteX, getAbsoluteY, getHeight, getHost, getParent, getWidth, getX, getY, hit, hoveredProperty, isActivationKey, isFocused, isHovered, isNarratable, isWithinBounds, onCharTyped, onFocusGained, onFocusLost, onHidden, onKeyPressed, onKeyReleased, onMouseDown, onMouseDrag, onMouseMove, onMouseScroll, onMouseUp, onShown, releaseFocus, renderTooltip, requestFocus, setHost, setHovered, setLocation, setParent, tick, validate
-
Field Details
-
text
protected net.minecraft.text.Text text -
color
protected int color -
darkmodeColor
protected int darkmodeColor -
horizontalAlignment
-
verticalAlignment
-
-
Constructor Details
-
WText
public WText(net.minecraft.text.Text text) -
WText
public WText(net.minecraft.text.Text text, int color)
-
-
Method Details
-
setSize
public void setSize(int x, int y) Description copied from class:WWidgetSets the size of this widget.Overriding methods may restrict one of the dimensions to be a constant value, for example
super.setSize(x, 20). -
canResize
public boolean canResize()Description copied from class:WWidgetChecks whether this widget can be resized usingWWidget.setSize(int, int). -
getTextStyleAt
@Environment(CLIENT) @Nullable public @Nullable net.minecraft.text.Style getTextStyleAt(int x, int y) Gets the text style at the specific widget-space coordinates.- Parameters:
x- the X coordinate in widget spacey- the Y coordinate in widget space- Returns:
- the text style at the position, or null if not found
-
paint
@Environment(CLIENT) public void paint(net.minecraft.client.util.math.MatrixStack matrices, int x, int y, int mouseX, int mouseY) Description copied from class:WWidgetPaints this widget. -
onClick
Description copied from class:WWidgetNotifies this widget that the mouse has been pressed and released, both while inside its bounds.- Overrides:
onClickin classWWidget- Parameters:
x- The X coordinate of the event, in widget-space (0 is the left edge of this widget)y- The Y coordinate of the event, in widget-space (0 is the top edge of this widget)button- The mouse button that was used. Button numbering is consistent with LWJGL Mouse (0=left, 1=right, 2=mousewheel click)- Returns:
InputResult.PROCESSEDif the event is handled,InputResult.IGNOREDotherwise.
-
getText
public net.minecraft.text.Text getText()Gets the text of this label.- Returns:
- the text
-
setText
Sets the text of this label.- Parameters:
text- the new text- Returns:
- this label
-
getColor
public int getColor()Gets the light mode color of this label.- Returns:
- the color
-
setColor
Sets the light mode color of this label.- Parameters:
color- the new color- Returns:
- this text widget
-
getDarkmodeColor
public int getDarkmodeColor()Gets the dark mode color of this label.- Returns:
- the color
- Since:
- 2.0.0
-
setDarkmodeColor
Sets the dark mode color of this label.- Parameters:
darkmodeColor- the new color- Returns:
- this text widget
-
setColor
Sets the light and dark mode colors of this label.- Parameters:
color- the new light colordarkmodeColor- the new dark color- Returns:
- this text widget
-
disableDarkmode
Disables separate dark mode coloring by copying the dark color to be the light color.- Returns:
- this text widget
-
getHorizontalAlignment
Gets the horizontal alignment of this text widget.- Returns:
- the alignment
- Since:
- 1.9.0
-
setHorizontalAlignment
Sets the horizontal alignment of this text widget.- Parameters:
horizontalAlignment- the new alignment- Returns:
- this widget
- Since:
- 1.9.0
-
getVerticalAlignment
Gets the vertical alignment of this text widget.- Returns:
- the alignment
- Since:
- 2.0.0
-
setVerticalAlignment
Sets the vertical alignment of this text widget.- Parameters:
verticalAlignment- the new alignment- Returns:
- this widget
- Since:
- 2.0.0
-
addNarrations
@Environment(CLIENT) public void addNarrations(net.minecraft.client.gui.screen.narration.NarrationMessageBuilder builder) Description copied from class:WWidgetAdds the narrations of this widget to a narration builder. Narrations will only apply if this widget is narratable.The widget needs to be focusable or hoverable, and also be focused/hovered for narrations to be added.
- Overrides:
addNarrationsin classWWidget- Parameters:
builder- the narration builder, cannot be null
-