R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
UI::ITextInput Class Referenceabstract

Abstract interface for UI text input fields. More...

#include <ITextInput.hpp>

Inheritance diagram for UI::ITextInput:
Inheritance graph
Collaboration diagram for UI::ITextInput:
Collaboration graph

Public Member Functions

virtual ~ITextInput ()=default
 Virtual destructor.
 
virtual void Update ()=0
 Update the text input internal state (focus, cursor, input).
 
virtual void Render ()=0
 Render the text input box.
 
virtual void SetOnTextChanged (std::function< void(const std::string &)> callback)=0
 Set callback invoked when text changes.
 
virtual void SetPosition (float x, float y)=0
 Set the top-left position of the text input.
 
virtual void GetPosition (float &x, float &y) const =0
 Get the current top-left position of the text input.
 
virtual void SetSize (float width, float height)=0
 Set the text input size.
 
virtual void GetSize (float &width, float &height) const =0
 Get the current size of the text input.
 
virtual void SetBackgroundColor (unsigned int color)=0
 Set the background color of the text input box.
 
virtual void SetBorderColor (unsigned int color)=0
 Set the border color when the input is not focused.
 
virtual void SetActiveBorderColor (unsigned int color)=0
 Set the border color when the input is focused/active.
 
virtual void SetTextColor (unsigned int color)=0
 Set the text color.
 
virtual void SetPlaceholderColor (unsigned int color)=0
 Set the placeholder text color (when input is empty).
 
virtual void SetTextSize (int size)=0
 Set the text size in pixels.
 
virtual void SetPlaceholder (const std::string &placeholder)=0
 Set the placeholder text displayed when the input is empty.
 
virtual void SetMaxLength (size_t maxLength)=0
 Set the maximum number of characters allowed.
 
virtual void SetValidationRegex (const std::string &regexPattern)=0
 Set a regex pattern to restrict allowed characters.
 
virtual const std::string & GetText () const =0
 Get the current text content.
 
virtual void SetText (const std::string &text)=0
 Set the text content programmatically.
 
virtual void Clear ()=0
 Clear the text content.
 
virtual bool IsFocused () const =0
 Check if the text input is currently focused/active.
 
virtual void SetFocused (bool focused)=0
 Set focus state programmatically.
 
virtual void SetFont (int fontHandle)=0
 Set the font handle for rendering text.
 
virtual void SetAlign (Align align)=0
 Set alignment mode relative to the window.
 
virtual Align GetAlign () const =0
 Get the current alignment mode.
 
virtual void ApplyAlignment ()=0
 Apply the current alignment mode to the position.
 
virtual void SetEnabled (bool enabled)=0
 Enable or disable the text input.
 
virtual bool IsEnabled () const =0
 Check if the text input is enabled.
 
virtual void SetPasswordMode (bool passwordMode)=0
 Enable or disable password mode (masks characters with asterisks).
 
virtual bool IsPasswordMode () const =0
 Check if password mode is enabled.
 

Detailed Description

Abstract interface for UI text input fields.

This interface defines a text input box with the following features:

  • Real-time text input with keyboard handling
  • Max character limit
  • Regex-based validation (prevents invalid characters from being typed)
  • Configurable appearance (size, position, colors)
  • Placeholder text when empty
  • Focus/blur states with visual feedback (border colors)
  • Blinking cursor when active
  • Optional callback on text change

Definition at line 32 of file ITextInput.hpp.

Constructor & Destructor Documentation

◆ ~ITextInput()

virtual UI::ITextInput::~ITextInput ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ ApplyAlignment()

virtual void UI::ITextInput::ApplyAlignment ( )
pure virtual

Apply the current alignment mode to the position.

Note
This modifies the position based on the align setting.

Implemented in UI::RaylibTextInput.

◆ Clear()

virtual void UI::ITextInput::Clear ( )
pure virtual

Clear the text content.

Implemented in UI::RaylibTextInput.

◆ GetAlign()

virtual Align UI::ITextInput::GetAlign ( ) const
pure virtual

Get the current alignment mode.

Returns
Alignment mode.

Implemented in UI::RaylibTextInput.

◆ GetPosition()

virtual void UI::ITextInput::GetPosition ( float &  x,
float &  y 
) const
pure virtual

Get the current top-left position of the text input.

Parameters
xOutput X position in pixels.
yOutput Y position in pixels.

Implemented in UI::RaylibTextInput.

◆ GetSize()

virtual void UI::ITextInput::GetSize ( float &  width,
float &  height 
) const
pure virtual

Get the current size of the text input.

Parameters
widthOutput width in pixels.
heightOutput height in pixels.

Implemented in UI::RaylibTextInput.

◆ GetText()

virtual const std::string & UI::ITextInput::GetText ( ) const
pure virtual

Get the current text content.

Returns
Current text string.

Implemented in UI::RaylibTextInput.

◆ IsEnabled()

virtual bool UI::ITextInput::IsEnabled ( ) const
pure virtual

Check if the text input is enabled.

Returns
true if enabled.

Implemented in UI::RaylibTextInput.

◆ IsFocused()

virtual bool UI::ITextInput::IsFocused ( ) const
pure virtual

Check if the text input is currently focused/active.

Returns
true if focused.

Implemented in UI::RaylibTextInput.

◆ IsPasswordMode()

virtual bool UI::ITextInput::IsPasswordMode ( ) const
pure virtual

Check if password mode is enabled.

Returns
true if password mode is enabled.

Implemented in UI::RaylibTextInput.

◆ Render()

virtual void UI::ITextInput::Render ( )
pure virtual

Render the text input box.

Note
Must be called between the backend BeginDrawing/EndDrawing calls.

Implemented in UI::RaylibTextInput.

◆ SetActiveBorderColor()

virtual void UI::ITextInput::SetActiveBorderColor ( unsigned int  color)
pure virtual

Set the border color when the input is focused/active.

Parameters
colorColor in ARGB format (0xAARRGGBB).

Implemented in UI::RaylibTextInput.

◆ SetAlign()

virtual void UI::ITextInput::SetAlign ( Align  align)
pure virtual

Set alignment mode relative to the window.

Parameters
alignAlignment mode.

Implemented in UI::RaylibTextInput.

◆ SetBackgroundColor()

virtual void UI::ITextInput::SetBackgroundColor ( unsigned int  color)
pure virtual

Set the background color of the text input box.

Parameters
colorColor in ARGB format (0xAARRGGBB).

Implemented in UI::RaylibTextInput.

◆ SetBorderColor()

virtual void UI::ITextInput::SetBorderColor ( unsigned int  color)
pure virtual

Set the border color when the input is not focused.

Parameters
colorColor in ARGB format (0xAARRGGBB).

Implemented in UI::RaylibTextInput.

◆ SetEnabled()

virtual void UI::ITextInput::SetEnabled ( bool  enabled)
pure virtual

Enable or disable the text input.

Parameters
enabledtrue to enable, false to disable.

Implemented in UI::RaylibTextInput.

◆ SetFocused()

virtual void UI::ITextInput::SetFocused ( bool  focused)
pure virtual

Set focus state programmatically.

Parameters
focusedtrue to focus, false to blur.

Implemented in UI::RaylibTextInput.

◆ SetFont()

virtual void UI::ITextInput::SetFont ( int  fontHandle)
pure virtual

Set the font handle for rendering text.

Parameters
fontHandleFont handle (-1 for default font).

Implemented in UI::RaylibTextInput.

◆ SetMaxLength()

virtual void UI::ITextInput::SetMaxLength ( size_t  maxLength)
pure virtual

Set the maximum number of characters allowed.

Parameters
maxLengthMaximum character count (0 = unlimited).

Implemented in UI::RaylibTextInput.

◆ SetOnTextChanged()

virtual void UI::ITextInput::SetOnTextChanged ( std::function< void(const std::string &)>  callback)
pure virtual

Set callback invoked when text changes.

Parameters
callbackFunction called when the text content changes.

Implemented in UI::RaylibTextInput.

◆ SetPasswordMode()

virtual void UI::ITextInput::SetPasswordMode ( bool  passwordMode)
pure virtual

Enable or disable password mode (masks characters with asterisks).

Parameters
passwordModetrue to mask characters, false to show them normally.

Implemented in UI::RaylibTextInput.

◆ SetPlaceholder()

virtual void UI::ITextInput::SetPlaceholder ( const std::string &  placeholder)
pure virtual

Set the placeholder text displayed when the input is empty.

Parameters
placeholderPlaceholder string.

Implemented in UI::RaylibTextInput.

◆ SetPlaceholderColor()

virtual void UI::ITextInput::SetPlaceholderColor ( unsigned int  color)
pure virtual

Set the placeholder text color (when input is empty).

Parameters
colorColor in ARGB format (0xAARRGGBB).

Implemented in UI::RaylibTextInput.

◆ SetPosition()

virtual void UI::ITextInput::SetPosition ( float  x,
float  y 
)
pure virtual

Set the top-left position of the text input.

Parameters
xX position in pixels.
yY position in pixels.

Implemented in UI::RaylibTextInput.

◆ SetSize()

virtual void UI::ITextInput::SetSize ( float  width,
float  height 
)
pure virtual

Set the text input size.

Parameters
widthWidth in pixels.
heightHeight in pixels.

Implemented in UI::RaylibTextInput.

◆ SetText()

virtual void UI::ITextInput::SetText ( const std::string &  text)
pure virtual

Set the text content programmatically.

Parameters
textNew text content.

Implemented in UI::RaylibTextInput.

◆ SetTextColor()

virtual void UI::ITextInput::SetTextColor ( unsigned int  color)
pure virtual

Set the text color.

Parameters
colorColor in ARGB format (0xAARRGGBB).

Implemented in UI::RaylibTextInput.

◆ SetTextSize()

virtual void UI::ITextInput::SetTextSize ( int  size)
pure virtual

Set the text size in pixels.

Parameters
sizeFont size.

Implemented in UI::RaylibTextInput.

◆ SetValidationRegex()

virtual void UI::ITextInput::SetValidationRegex ( const std::string &  regexPattern)
pure virtual

Set a regex pattern to restrict allowed characters.

Parameters
regexPatternRegex pattern string (e.g., "[a-zA-Z0-9]+" for alphanumeric only). Empty string = no restriction.
Note
Validation is applied in real-time: invalid characters are rejected on input.

Implemented in UI::RaylibTextInput.

◆ Update()

virtual void UI::ITextInput::Update ( )
pure virtual

Update the text input internal state (focus, cursor, input).

Note
Should be called once per frame.

Implemented in UI::RaylibTextInput.


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