Class Text
A text input control that allows users to enter and edit text
Implements
Inherited Members
Namespace: PopcorningGuineaPig.Engine.UI
Assembly: PopcorningGuineaPig.Engine.dll
Syntax
public class Text : InteractiveUIElement, IUIElement
Constructors
| Edit this page View SourceText(Vector2, Vector2, string)
Constructor for the Text control
Declaration
public Text(Vector2 position, Vector2 size, string initialText = "")
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | position | Position of the control |
| Vector2 | size | Size of the control |
| string | initialText | Initial text content |
Methods
| Edit this page View SourceDrawSelf()
Override DrawSelf to render the text control
Declaration
protected override void DrawSelf()
Overrides
| Edit this page View SourceFocus()
Manually focuses the text control
Declaration
public void Focus()
GetText()
Gets the current text content
Declaration
public string GetText()
Returns
| Type | Description |
|---|---|
| string | The current text |
IsFocused()
Gets whether the control is currently focused
Declaration
public bool IsFocused()
Returns
| Type | Description |
|---|---|
| bool | True if focused, false otherwise |
SetColors(Color, Color, Color, Color)
Sets the visual colors for the text control
Declaration
public void SetColors(Color backgroundColor, Color textColor, Color borderColor, Color focusedBorderColor)
Parameters
| Type | Name | Description |
|---|---|---|
| Color | backgroundColor | Background color |
| Color | textColor | Text color |
| Color | borderColor | Border color when not focused |
| Color | focusedBorderColor | Border color when focused |
SetFontSize(int)
Sets the font size for the text
Declaration
public void SetFontSize(int fontSize)
Parameters
| Type | Name | Description |
|---|---|---|
| int | fontSize | Font size in pixels |
SetLocalizationService(ILocalizationService?)
Sets the localization service for font management
Declaration
public override void SetLocalizationService(ILocalizationService? localizationService)
Parameters
| Type | Name | Description |
|---|---|---|
| ILocalizationService | localizationService | The localization service to use |
Overrides
| Edit this page View SourceSetOnEnterPressed(Action<string>)
Sets the callback for when Enter is pressed
Declaration
public void SetOnEnterPressed(Action<string> callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<string> | callback | Callback function that receives the current text |
SetOnFocusGained(Action)
Sets the callback for when the control gains focus
Declaration
public void SetOnFocusGained(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | Callback function |
SetOnFocusLost(Action)
Sets the callback for when the control loses focus
Declaration
public void SetOnFocusLost(Action callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | callback | Callback function |
SetOnTextChanged(Action<string>)
Sets the callback for when text changes
Declaration
public void SetOnTextChanged(Action<string> callback)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<string> | callback | Callback function that receives the new text |
SetPadding(int)
Sets the padding inside the control
Declaration
public void SetPadding(int padding)
Parameters
| Type | Name | Description |
|---|---|---|
| int | padding | Padding in pixels |
SetText(string)
Sets the text content of the control
Declaration
public void SetText(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The new text content |
Unfocus()
Manually unfocuses the text control
Declaration
public void Unfocus()
UpdateSelf()
Override UpdateSelf to handle text input logic
Declaration
protected override void UpdateSelf()