Class WritableTextBoxObject
java.lang.Object
com.iragui.objects.GUIObject
com.iragui.objects.TextBoxObject
com.iragui.objects.WritableTextBoxObject
A writable text box GUI component that supports user input, cursor movement,
multi-line editing, and different editing modes.
Extends TextBoxObject
by adding keyboard and mouse interaction,
cursor rendering, and text-editing logic (insert, backspace, newline, etc.).
Supported Modes
CONSOLE_MODE
- Appends text at the end, typical console input behavior.FREE_MODE
- Allows free multi-line editing.TEXT_EDITOR_MODE
- Full text editor behavior with insert, newline, and merge logic.
Line Limit
You may set a line limit usingsetLineLimit(int)
.
If set to NO_LINE_LIMIT
, unlimited lines are allowed.
Cursor
ATextObject
cursor is maintained internally and updated during editing.
Usage
Example:WritableTextBoxObject textBox = new WritableTextBoxObject( "chatBox", 1, gui, 50, 50, 400, 300, false, true, 4, mySubWindow, myFont, Color.WHITE, new Color(0,0,0,0), true ); textBox.setMode(WritableTextBoxObject.TEXT_EDITOR_MODE);
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic int
Console mode: appends text at the end.Cursor object rendered as a text glyph (e.g., "|").boolean
Whether this text box is currently focused for input.static int
Free mode: allows arbitrary line navigation and editing.static int
Text editor mode: supports full editing logic (newlines, merging lines, etc.).static int
Text editor mode: supports full editing logic (newlines, merging lines, etc.).Fields inherited from class com.iragui.objects.TextBoxObject
lines
-
Constructor Summary
ConstructorsConstructorDescriptionWritableTextBoxObject
(String name, int layer, GUI gui, int x, int y, int sizeX, int sizeY, boolean nearestFilter, boolean rgba, int lineSpacing, SubWindowObject window, Font font, Color textColor, Color backgroundColor, boolean antiAliasing) Creates a writable text box object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendLine
(String text) Appends a new line of text to the text box.void
Destroys this object, releasing GPU resources and unregistering it.int
getLines()
int
getMode()
void
sendKey
(int key, int action) Handles a keyboard key event.void
sendMouseButton
(long window, int button, int action, int mods) Handles mouse button input.void
sendMousePos
(long window, double xPos, double yPos) Handles mouse position updates.void
setLayer
(int layer) Sets the rendering layer and updates parent GUI ordering.void
setLineLimit
(int l) Sets the maximum line count for this text box.void
setMode
(int mode) Sets the editing mode for this text box.void
setX
(int x) Sets the X position in pixels.void
setY
(int y) Sets the Y position in pixels.void
update
(boolean showFrame) Updates the text box state (cursor position, pending writes, etc.).Methods inherited from class com.iragui.objects.TextBoxObject
appendLine, getLineSpacing, sendMouseScroll, setLimitX, setLimitY, setLineSpacing, setMinX, setMinY, setWinLimitX, setWinLimitY, setWinMinX, setWinMinY
Methods inherited from class com.iragui.objects.GUIObject
allowReTexture, focus, getGlPixelInt, getHFlip, getLayer, getLimitX, getLimitY, getMinX, getMinY, getRotation, getScale, getSizeX, getSizeY, getTextureID, getVFlip, getVisible, getWinLimitX, getWinLimitY, getWinMinX, getWinMinY, getX, getY, hide, includesKeyCallback, includesMouseCallback, interactionInVisibleBounds, isDestroyed, isFocused, isNearestFilter, render, resetTextureID, setAll, setAll, setHFlip, setNearestFilter, setPixel, setPreserveTextureIDOverride, setRotation, setScale, setTextureID, setVFlip, setVisible, unfocus, updates
-
Field Details
-
focused
public boolean focusedWhether this text box is currently focused for input. -
cursor
Cursor object rendered as a text glyph (e.g., "|"). -
CONSOLE_MODE
public static int CONSOLE_MODEConsole mode: appends text at the end. -
FREE_MODE
public static int FREE_MODEFree mode: allows arbitrary line navigation and editing. -
TEXT_EDITOR_MODE
public static int TEXT_EDITOR_MODEText editor mode: supports full editing logic (newlines, merging lines, etc.). -
NO_LINE_LIMIT
public static int NO_LINE_LIMITText editor mode: supports full editing logic (newlines, merging lines, etc.).
-
-
Constructor Details
-
WritableTextBoxObject
public WritableTextBoxObject(String name, int layer, GUI gui, int x, int y, int sizeX, int sizeY, boolean nearestFilter, boolean rgba, int lineSpacing, SubWindowObject window, Font font, Color textColor, Color backgroundColor, boolean antiAliasing) Creates a writable text box object.- Parameters:
name
- object namelayer
- rendering layergui
- GUI managerx
- x positiony
- y positionsizeX
- widthsizeY
- heightnearestFilter
- true to use nearest-neighbor scalingrgba
- whether RGBA is enabledlineSpacing
- line spacing in pixelswindow
- parent sub-window object (optional, can be null)font
- font for rendering texttextColor
- foreground text colorbackgroundColor
- background colorantiAliasing
- whether to enable anti-aliasing
-
-
Method Details
-
setLineLimit
public void setLineLimit(int l) Sets the maximum line count for this text box.- Parameters:
l
- line limit, orNO_LINE_LIMIT
for unlimited lines
-
getLineLimit
public int getLineLimit()- Returns:
- the maximum line count, or
NO_LINE_LIMIT
if unlimited
-
setMode
public void setMode(int mode) Sets the editing mode for this text box.- Parameters:
mode
- one ofCONSOLE_MODE
,FREE_MODE
,TEXT_EDITOR_MODE
-
getMode
public int getMode()- Returns:
- the current editing mode
-
appendLine
Appends a new line of text to the text box.- Parameters:
text
- line text to append
-
sendKey
public void sendKey(int key, int action) Handles a keyboard key event.- Overrides:
sendKey
in classTextBoxObject
- Parameters:
key
- GLFW key codeaction
- GLFW action (press, release, repeat)
-
destroyObject
public void destroyObject()Description copied from class:TextBoxObject
Destroys this object, releasing GPU resources and unregistering it.If
preserveTextureIDOverride
is true, the OpenGL texture ID will not be deleted. SeeGUIObject.setPreserveTextureIDOverride(boolean)
.- Overrides:
destroyObject
in classTextBoxObject
-
update
public void update(boolean showFrame) Updates the text box state (cursor position, pending writes, etc.).- Overrides:
update
in classTextBoxObject
- Parameters:
showFrame
- true if the GUI should be refreshed
-
sendMousePos
public void sendMousePos(long window, double xPos, double yPos) Description copied from class:GUIObject
Handles mouse position updates.- Overrides:
sendMousePos
in classTextBoxObject
-
setLayer
public void setLayer(int layer) Description copied from class:TextBoxObject
Sets the rendering layer and updates parent GUI ordering.- Overrides:
setLayer
in classTextBoxObject
-
sendMouseButton
public void sendMouseButton(long window, int button, int action, int mods) Description copied from class:GUIObject
Handles mouse button input.- Overrides:
sendMouseButton
in classTextBoxObject
-
setX
public void setX(int x) Description copied from class:TextBoxObject
Sets the X position in pixels.- Overrides:
setX
in classTextBoxObject
-
setY
public void setY(int y) Description copied from class:TextBoxObject
Sets the Y position in pixels.- Overrides:
setY
in classTextBoxObject
-
getLines
- Overrides:
getLines
in classTextBoxObject
- Returns:
- the lines in this text box
-