cangine
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
cangine::InputField Class Reference

Editable text-field game object. More...

#include <inputfield_object.hpp>

Inheritance diagram for cangine::InputField:
Inheritance graph
[legend]
Collaboration diagram for cangine::InputField:
Collaboration graph
[legend]

Public Member Functions

 InputField ()
 Constructs an input field with a default style.
 
void setContent (std::string contentIn)
 Sets the field's text content and refreshes the view.
 
void setPlaceholder (std::string placeholderIn)
 Sets the placeholder text shown when empty.
 
void setCursorPos (int posIn)
 Sets the caret position and refreshes the view.
 
void setWidth (float widthIn)
 Sets the field width.
 
void setHeight (float heightIn)
 Sets the field height (and scales the font to match).
 
void setBorderWidth (float widthIn)
 Sets the border thickness.
 
void setPlaceHolderColor (Color colorIn)
 Sets the placeholder text color.
 
void setBorderColor (Color colorIn)
 Sets the border color when unfocused.
 
void setBorderColorFocus (Color colorIn)
 Sets the border color when focused.
 
void setCursorColor (Color colorIn)
 Sets the caret color.
 
void setBackgroundColor (Color colorIn)
 Sets the field background color.
 
void setColor (Color colorIn)
 Sets the text color.
 
void setOnReturn (std::function< void(std::string)> functionIn)
 Sets the callback invoked when Enter is pressed.
 
InputFieldComponent * getIFC ()
 Returns the underlying input field component.
 
const std::string & getContent () const
 Returns the current content.
 
const std::string & getPlaceholder () const
 Returns the placeholder text.
 
int getCursorPos () const
 Returns the caret position.
 
float getWidth () const
 Returns the field width.
 
float getHeight () const
 Returns the field height.
 
float getBorderWidth () const
 Returns the border thickness.
 
const Color & getPlaceholderColor () const
 Returns the placeholder text color.
 
const Color & getBorderColor () const
 Returns the unfocused border color.
 
const Color & getBorderColorFocus () const
 Returns the focused border color.
 
const Color & getCursorColor () const
 Returns the caret color.
 
const Color & getBackgroundColor () const
 Returns the background color.
 
const Color & getColor () const
 Returns the text color.
 
- Public Member Functions inherited from cangine::GameObject
 GameObject ()
 
virtual ~GameObject ()
 
virtual void onUpdate (double deltaTime)
 Per-frame update hook.
 
virtual void onMouseEvent (const MouseEvent *e)
 Mouse event hook.
 
virtual void onDisable ()
 Called when the object becomes inactive.
 
virtual void onEnable ()
 Called when the object becomes active.
 
void destroy ()
 Marks the object for destruction by the ObjectManager.
 
template<typename T >
void appendComponent (T *component)
 Attaches an existing component to this object.
 
template<typename T >
void destroyComponent ()
 Destroys and removes the first component of a type.
 
template<typename T >
T * getComponent ()
 Returns the first attached component of a type.
 
template<typename T >
std::vector< T * > getComponents ()
 Returns all attached components of a type.
 
template<typename T , typename... Args>
T * newComponent (Args &&... args)
 Constructs a component in place and attaches it.
 
void setActive (bool a)
 Activates or deactivates the object.
 
bool isActive ()
 Reports whether the object is active.
 

Private Attributes

InputFieldComponent * ifc
 Component implementing the input field.
 

Detailed Description

Editable text-field game object.

A thin convenience wrapper around InputFieldComponent, exposing getters and setters for the field's content, style and the on-return callback so it can be configured without touching the component.

Constructor & Destructor Documentation

◆ InputField()

cangine::InputField::InputField ( )

Constructs an input field with a default style.

Member Function Documentation

◆ getBackgroundColor()

const Color & cangine::InputField::getBackgroundColor ( ) const
inline

Returns the background color.

Returns
Reference to the background color.

◆ getBorderColor()

const Color & cangine::InputField::getBorderColor ( ) const
inline

Returns the unfocused border color.

Returns
Reference to the border color.

◆ getBorderColorFocus()

const Color & cangine::InputField::getBorderColorFocus ( ) const
inline

Returns the focused border color.

Returns
Reference to the focused border color.

◆ getBorderWidth()

float cangine::InputField::getBorderWidth ( ) const
inline

Returns the border thickness.

Returns
Border width in pixels.

◆ getColor()

const Color & cangine::InputField::getColor ( ) const
inline

Returns the text color.

Returns
Reference to the text color.

◆ getContent()

const std::string & cangine::InputField::getContent ( ) const
inline

Returns the current content.

Returns
Reference to the content string.

◆ getCursorColor()

const Color & cangine::InputField::getCursorColor ( ) const
inline

Returns the caret color.

Returns
Reference to the caret color.

◆ getCursorPos()

int cangine::InputField::getCursorPos ( ) const
inline

Returns the caret position.

Returns
Caret index into the content.

◆ getHeight()

float cangine::InputField::getHeight ( ) const
inline

Returns the field height.

Returns
Height in pixels.

◆ getIFC()

InputFieldComponent * cangine::InputField::getIFC ( )
inline

Returns the underlying input field component.

Returns
The InputFieldComponent.

◆ getPlaceholder()

const std::string & cangine::InputField::getPlaceholder ( ) const
inline

Returns the placeholder text.

Returns
Reference to the placeholder string.

◆ getPlaceholderColor()

const Color & cangine::InputField::getPlaceholderColor ( ) const
inline

Returns the placeholder text color.

Returns
Reference to the placeholder color.

◆ getWidth()

float cangine::InputField::getWidth ( ) const
inline

Returns the field width.

Returns
Width in pixels.

◆ setBackgroundColor()

void cangine::InputField::setBackgroundColor ( Color  colorIn)
inline

Sets the field background color.

Parameters
colorInNew color.

◆ setBorderColor()

void cangine::InputField::setBorderColor ( Color  colorIn)
inline

Sets the border color when unfocused.

Parameters
colorInNew color.

◆ setBorderColorFocus()

void cangine::InputField::setBorderColorFocus ( Color  colorIn)
inline

Sets the border color when focused.

Parameters
colorInNew color.

◆ setBorderWidth()

void cangine::InputField::setBorderWidth ( float  widthIn)
inline

Sets the border thickness.

Parameters
widthInNew border width in pixels.

◆ setColor()

void cangine::InputField::setColor ( Color  colorIn)
inline

Sets the text color.

Parameters
colorInNew color.

◆ setContent()

void cangine::InputField::setContent ( std::string  contentIn)
inline

Sets the field's text content and refreshes the view.

Parameters
contentInNew content string.

◆ setCursorColor()

void cangine::InputField::setCursorColor ( Color  colorIn)
inline

Sets the caret color.

Parameters
colorInNew color.

◆ setCursorPos()

void cangine::InputField::setCursorPos ( int  posIn)
inline

Sets the caret position and refreshes the view.

Parameters
posInNew caret index into the content.

◆ setHeight()

void cangine::InputField::setHeight ( float  heightIn)
inline

Sets the field height (and scales the font to match).

Parameters
heightInNew height in pixels.

◆ setOnReturn()

void cangine::InputField::setOnReturn ( std::function< void(std::string)>  functionIn)
inline

Sets the callback invoked when Enter is pressed.

Parameters
functionInCallback receiving the field content.

◆ setPlaceholder()

void cangine::InputField::setPlaceholder ( std::string  placeholderIn)
inline

Sets the placeholder text shown when empty.

Parameters
placeholderInNew placeholder string.

◆ setPlaceHolderColor()

void cangine::InputField::setPlaceHolderColor ( Color  colorIn)
inline

Sets the placeholder text color.

Parameters
colorInNew color.

◆ setWidth()

void cangine::InputField::setWidth ( float  widthIn)
inline

Sets the field width.

Parameters
widthInNew width in pixels.

Member Data Documentation

◆ ifc

InputFieldComponent* cangine::InputField::ifc
private

Component implementing the input field.


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