# SUIInputField

## Index

### Functions Index

| Function Name                                                 |
| ------------------------------------------------------------- |
| void [**OnValueChanged** ](#onvaluechanged)(Closure callback) |
| void [**OnEndEdit** ](#onendedit)(Closure callback)           |
| void [**ActivateInputField** ](#activateinputfield)()         |
| void [**DeactivateInputField** ](#deactivateinputfield)()     |
| void [**Select** ](#select)()                                 |

### Properties Index

| Property Name                                                           |
| ----------------------------------------------------------------------- |
| string [**Text** ](#text)`get` `set`                                    |
| bool [**Enabled** ](#enabled)`get` `set`                                |
| bool [**Interactable** ](#interactable)`get` `set`                      |
| bool [**IsFocused** ](#isfocused)`get`                                  |
| float [**CaretBlinkRate** ](#caretblinkrate)`get` `set`                 |
| int [**CaretWidth** ](#caretwidth)`get` `set`                           |
| int [**CharacterLimit** ](#characterlimit)`get` `set`                   |
| bool [**ReadOnly** ](#readonly)`get` `set`                              |
| bool [**MultiLine** ](#multiline)`get`                                  |
| char [**AsteriskChar** ](#asteriskchar)`get` `set`                      |
| int [**CaretPosition** ](#caretposition)`get` `set`                     |
| int [**SelectionAnchorPosition** ](#selectionanchorposition)`get` `set` |
| int [**SelectionFocusPosition** ](#selectionfocusposition)`get` `set`   |
| float [**MinWidth** ](#minwidth)`get`                                   |
| float [**PreferredWidth** ](#preferredwidth)`get`                       |
| float [**FlexibleWidth** ](#flexiblewidth)`get`                         |
| float [**MinHeight** ](#minheight)`get`                                 |
| float [**PreferredHeight** ](#preferredheight)`get`                     |
| float [**FlexibleHeight** ](#flexibleheight)`get`                       |
| SColor [**NormalColor** ](#normalcolor)`get` `set`                      |
| SColor [**HighlightedColor** ](#highlightedcolor)`get` `set`            |
| SColor [**PressedColor** ](#pressedcolor)`get` `set`                    |
| SColor [**DisabledColor** ](#disabledcolor)`get` `set`                  |
| float [**ColorMultiplier** ](#colormultiplier)`get` `set`               |
| SGameObject [**GameObject** ](#gameobject)`get`                         |

## Functions

### OnValueChanged

void **OnValueChanged** (Closure callback)

*Given function will be called when text in Input Field has changed*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
function OVC()
--
end
Space.Host.ExecutingObject.UIInputField.OnValueChanged(OVC)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--This script will make an input field update a text field 
--with character count in real-time every time a character is typed/removed
--[Text field and Input fields need to be added as references (scripting runtime)]

thisObject = Space.Host.ExecutingObject
inputField = Space.Host.GetReference("The Input Field").UIInputField
textField = Space.Host.GetReference("The Text Field").UIText

OnValueChanged = function()
 textField.Text =  "Count= " .. string.len(inputField.Text)
end

thisObject.UIInputField.OnValueChanged(OnValueChanged)
```

{% endtab %}
{% endtabs %}

### OnEndEdit

void **OnEndEdit** (Closure callback)

*Given function will be called when editing has ended*

| Parameter | Type | Description |
| --------- | ---- | ----------- |
|           |      |             |

{% tabs %}
{% tab title="Lua" %}

```lua
function OEE()
--
end
Space.Host.ExecutingObject.UIInputField.OnEndEdit(OEE)
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--This script will make an input field update a text field 
--as soon as someone has finished typing in it
--Text field and Input fields need to be added as references (scripting runtime)

thisObject = Space.Host.ExecutingObject
inputField = Space.Host.GetReference("The Input Field").UIInputField
textField = Space.Host.GetReference("The Text Field").UIText

OnEndEdit = function()
 textField.Text = inputField.Text
end

Space.Host.ExecutingObject.UIInputField.OnEndEdit(OnEndEdit)
```

{% endtab %}
{% endtabs %}

### ActivateInputField

void **ActivateInputField** ()

*Function Description*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.ActivateInputField()
```

{% endtab %}
{% endtabs %}

### DeactivateInputField

void **DeactivateInputField** ()

*Function Description*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.DeactivateInputField()
```

{% endtab %}
{% endtabs %}

### Select

void **Select** ()

*Function Description*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.DeactivateInputField()
```

{% endtab %}
{% endtabs %}

## Properties

### Text

string **Text** `get` `set`

*The current value of the input field.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.Text= "Hello"
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--the below script makes this object set Browser URL according to what's written in text field
--[Required: This object needs a Browser and InputField objects to be added as reference to references section in Scripting Runtime component]

thisGameObject = Space.Host.ExecutingObject
webBrowser = Space.Host.GetReference("Browser")
urlField = Space.Host.GetReference("URL Field")

OnClick = function()

webBrowser.Browser.SetURL = urlField.UIInputField.Text

end

urlField.UIInputField.Text = https://www.youtube.com
thisGameObject.AddClickable()
thisGameObject.Clickable.Tooltip = "Click to set URL"
thisGameObject.Clickable.OnClick(OnClick)  
```

{% endtab %}
{% endtabs %}

### Enabled

bool **Enabled** `get` `set`

*Whether this Input Field component is Enabled*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.Enabled= true
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking this object will toggle a UIInputField's Enabled status

thisGameObject = Space.Host.ExecutingObject
inputfield = Space.Host.GetReference("inputfield").UIInputField 
--make sure to add this reference to the Scripting Runtime component


OnClick = function()
inputfield.Enabled =  not inputfield.Enabled
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)
```

{% endtab %}
{% endtabs %}

### Interactable

bool **Interactable** `get` `set`

*Is the Input Field interactable?*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.Interactable= true
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking this object will toggle a UIInputField's interactable status
thisGameObject = Space.Host.ExecutingObject
inputfield = Space.Host.GetReference("inputfield").UIInputField 
--make sure to add this reference to the Scripting Runtime component



OnClick = function()
inputfield.Interactable =  not inputfield.Interactable
end



thisGameObject.AddClickable()


thisGameObject.Clickable.OnClick(OnClick)
```

{% endtab %}
{% endtabs %}

### IsFocused

bool **IsFocused** `get`

*Does the InputField currently have focus and is able to process events.*

{% tabs %}
{% tab title="Lua" %}

```lua
hasFocus = Space.Host.ExecutingObject.UIInputField.IsFocused 
```

{% endtab %}
{% endtabs %}

### CaretBlinkRate

float **CaretBlinkRate** `get` `set`

*The blinking rate of the input caret, defined as the number of times the blink cycle occurs per second.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.CaretBlinkRate= 3
```

{% endtab %}
{% endtabs %}

### CaretWidth

int **CaretWidth** `get` `set`

*The width of the caret in pixels.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.CaretWidth= 4
```

{% endtab %}
{% endtabs %}

### CharacterLimit

int **CharacterLimit** `get` `set`

*Property Description*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.CharacterLimit= 8
```

{% endtab %}
{% endtabs %}

### ReadOnly

bool **ReadOnly** `get` `set`

*Property Description*

{% tabs %}
{% tab title="Lua" %}

```lua
Is the InputField read only?
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Lua" %}

```lua
--clicking this object will toggle a UIInputField's ReadOnly status

thisGameObject = Space.Host.ExecutingObject
inputfield = Space.Host.GetReference("inputfield").UIInputField 
--make sure to add this reference to the Scripting Runtime component


OnClick = function()
inputfield.ReadOnly =  not inputfield.ReadOnly
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)
```

{% endtab %}
{% endtabs %}

### MultiLine

bool **MultiLine** `get`

*If the input field supports multiple lines.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.MultiLine = true
```

{% endtab %}
{% endtabs %}

### AsteriskChar

char **AsteriskChar** `get` `set`

*The character used for password fields.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.AsteriskChar= "%"
```

{% endtab %}
{% endtabs %}

### CaretPosition

int **CaretPosition** `get` `set`

*Current InputField caret position (also selection tail).*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.CaretPosition= 3
```

{% endtab %}
{% endtabs %}

### SelectionAnchorPosition

int **SelectionAnchorPosition** `get` `set`

*The beginning point of the selection.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.SelectionAnchorPosition= 1
```

{% endtab %}
{% endtabs %}

### SelectionFocusPosition

int **SelectionFocusPosition** `get` `set`

*The end point of the selection.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.SelectionFocusPosition= 4
```

{% endtab %}
{% endtabs %}

### MinWidth

float **MinWidth** `get`

*The minimum width this UIInputField may be allocated. (Used by the Layout system).*

{% tabs %}
{% tab title="Lua" %}

```lua
minWidth = Space.Host.ExecutingObject.UIInputField.MinWidth
```

{% endtab %}
{% endtabs %}

### PreferredWidth

float **PreferredWidth** `get`

*The preferred width this UIInputField should be allocated if there is sufficient space. (Used by the Layout system)*

{% tabs %}
{% tab title="Lua" %}

```lua
prefWidth = Space.Host.ExecutingObject.UIInputField.PreferredWidth
```

{% endtab %}
{% endtabs %}

### FlexibleWidth

float **FlexibleWidth** `get`

*The extra relative width this UIInputField should be allocated if there is additional available space. (Used by the Layout system)*

{% tabs %}
{% tab title="Lua" %}

```lua
flexWidth = Space.Host.ExecutingObject.UIInputField.FlexibleWidth
```

{% endtab %}
{% endtabs %}

### MinHeight

float **MinHeight** `get`

*The minimum height this UIInputField may be allocated.(Used by the Layout system).*

{% tabs %}
{% tab title="Lua" %}

```lua
minHeight = Space.Host.ExecutingObject.UIInputField.MinHeight
```

{% endtab %}
{% endtabs %}

### PreferredHeight

float **PreferredHeight** `get`

*The preferred height this UIInputField should be allocated if there is sufficient space. (Used by the Layout system)*

{% tabs %}
{% tab title="Lua" %}

```lua
prefHeight = Space.Host.ExecutingObject.UIInputField.PreferredHeight
```

{% endtab %}
{% endtabs %}

### FlexibleHeight

float **FlexibleHeight** `get`

*The extra relative height this UIInputField should be allocated if there is additional available space. (Used by the Layout system)*

{% tabs %}
{% tab title="Lua" %}

```lua
flexHeight = Space.Host.ExecutingObject.UIInputField.FlexibleHeight
```

{% endtab %}
{% endtabs %}

### NormalColor

SColor **NormalColor** `get` `set`

*The normal color.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.NormalColor = Color.Red
```

{% endtab %}
{% endtabs %}

### HighlightedColor

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **HighlightedColor** `get` `set`

*The color of the control when it is highlighted.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.HighlightedColor = Color.Red
```

{% endtab %}
{% endtabs %}

### PressedColor

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **PressedColor** `get` `set`

*The color of the control when it is pressed.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.PressedColor = Color.Red
```

{% endtab %}
{% endtabs %}

### DisabledColor

[SColor](https://docs.sine.space/scripting/client-scripting-api-reference/types/scolor) **DisabledColor** `get` `set`

*The color of the control when it is disabled.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.DisabledColor = Color.Red
```

{% endtab %}
{% endtabs %}

### ColorMultiplier

float **ColorMultiplier** `get` `set`

*This multiplies the tint color for each transition by its value.*

{% tabs %}
{% tab title="Lua" %}

```lua
Space.Host.ExecutingObject.UIInputField.ColorMultiplier = Color.Red
```

{% endtab %}
{% endtabs %}

### GameObject

[SGameObject](https://docs.sine.space/scripting/client-scripting-api-reference/types/sgameobject) **GameObject** `get`

*Property Description*

{% tabs %}
{% tab title="Lua" %}

<pre class="language-lua"><code class="lang-lua"><strong>theGameObject = Space.Host.ExecutingObject.UIInputField.GameObject
</strong></code></pre>

{% endtab %}
{% endtabs %}
