JMgui
Loading...
Searching...
No Matches
TextBox Class Reference

A text input box. More...

#include <JMgui.h>

Inheritance diagram for TextBox:
GuiElement

Classes

class  TextInputEvent
class  FloatInputEvent

Public Member Functions

 TextBox (float PosX, float PosY, float Length)
 TextBox (float PosX, float PosY, float Length, std::string Title)
void render ()
 draw the element to the buffer. Override this to make the element custom.
std::string getInput () const
float getInputFloat () const
bool setInput (std::string newInput)
 If the new input is allowed, sets the text input and triggers the appropriate events.
bool setInput (float newInput)
 If the new input is allowed, sets the text input and triggers the appropriate events.
bool setInputWithoutEvent (std::string newInput)
bool setInputWithoutEvent (float newInput)
bool newInput () const
 returns true if a new input was typed.
Public Member Functions inherited from GuiElement
 GuiElement (float PosX, float PosY, float SizeX, float SizeY)
 GuiElement (GuiElement &)=delete
GuiElementoperator= (const GuiElement &)=delete
 GuiElement (GuiElement &&)=default
GuiElementoperator= (GuiElement &&)=default
virtual void setup (GuiElementHandler *Handler)
virtual void setup (JMwindow *Window)
float width () const
float height () const
float xPos () const
float yPos () const
void setPosition (float x, float y)
void setSize (float x, float y)
void setSizeX (float x)
void setSizeY (float y)
bool mouseOver () const
 returns true if the mouse is over the element.
float localMouseX () const
 Returns the mouse position relative to the bottom left corner of the element.
float localMouseY () const
 Returns the mouse position relative to the bottom left corner of the element.
bool clicked () const
 returns true if the mouse is over the element and the left button is pressed and released.
bool rightClicked () const
 returns true if the mouse is over the element and the right button is pressed and released.
bool pressed () const
 returns true if the mouse is over the element and the left button is pressed.
virtual void display ()
 is called by the element handler to display the element on the screen.
int renderLayer ()

Public Attributes

bool allowNum = true
bool allowNeg = true
bool allowZero = true
bool allowLetters = true
bool allowSymbols = true
bool allowEmpty = true
TextInputEventevent_textInput
FloatInputEventevent_floatInput
Public Attributes inherited from GuiElement
float dispTitleX = 0.0f
float dispTitleY = 0.0f
bool allowInput = true
 used to prevent user input to this element if needed.
bool forceAllowInput = false
 if true, when the element handlers allowInput is set to false, this element will be exempt.
bool hide = false
 the element is not updated or displayed if true
bool constantUpdate = false
 Set this to true to re-render the element every frame. By default, the element is only re-rendered when animating (mouse over animation and pressed animation).
bool staticElement = false
 if true, the element will only be rendered for the startup animation or if the window is resized, then displayed staticly. User input will not work.
bool reRender = false
 If set to true, the element is re-rendered once, then this is set to false.
std::string helpMessage = ""
 The help message that displays when the mouse is hovered over the object.
JMwindowwindow = nullptr
 the window that this element is drawn to.
ClickEventevent_clicked = nullptr
RightClickEventevent_rightClicked = nullptr
std::string displayTitle = ""

Additional Inherited Members

Protected Member Functions inherited from GuiElement
void registerEvent (JMeventDispatcher::Event *event)
 adds an event to the window's event handler.
Protected Attributes inherited from GuiElement
int RenderLayer = 0
GuiElementHandlerhandler = nullptr
 the handler object that this element is drawn by.
JMGraphics * gr = nullptr
 the graphics object of the parent window. use this objects graphics functions to draw the ui element.
JMGraphics::Buffer * graphicsBuffer = nullptr
 the element is drawn to a graphics buffer so that the graphics only have to be generated when nescecary, and still displayed on the screen every frame.
JMGraphics::Font * dispTitleFont = nullptr
 The font used to render the title.
float posX = 0.0f
float posY = 0.0f
float sizeX = 0.0f
float sizeY = 0.0f
glm::vec2 dispTitleSize = glm::vec2(0.0f, 0.0f)
 stores the physical size of the displayed title
float dispTitleScale = 1.0f
 sets the physical size of the title
float anim_start = 0.0f
 use to create a startup animation. Increases from 0.0f to 1.0f over time when the element is first displayed.
float anim_mouseOver = 0.0f
 use to create a mouse over animation. Increases from 0.0f to 1.0f over time when the mouse is over the element.
float anim_pressed = 0.0f
 use to create a pressed animation. Increases from 0.0f to 1.0f over time when the element is pressed with the mouse.
float anim_clicked = 0.0f
 use to create a clicked animation. When the element is clicked, it will be set to 1.0f, then decrease to 0.0f over time.
bool fixedX = false
 If true, the element cannot be resized on the x axis.
bool fixedY = false
 If true, the element cannot be resized on the y axis.

Detailed Description

A text input box.

Member Function Documentation

◆ render()

void TextBox::render ( )
virtual

draw the element to the buffer. Override this to make the element custom.

Reimplemented from GuiElement.


The documentation for this class was generated from the following file: