wiki.sine.space | sinespace

Difference between revisions of "Scripting/SUIInputField"

From wiki.sine.space
Jump to: navigation, search
(Replaced content with "This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/suiinputfield")
 
Line 1: Line 1:
=Members=
+
This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/suiinputfield
 
+
{{ScriptFunction|void|OnEndEdit|(closure callback)|Given function will be called when editing has ended|5=<pre>oee = function()
+
  Space.Log("edit ended")
+
end
+
Space.Host.ExecutingObject.UIInputField.OnEndEdit(oee)</pre>|6=<pre>--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)</pre>}}
+
 
+
{{ScriptFunction|void|OnValueChanged|(closure callback)|Given function will be called when text in Input Field has changed|5=<pre>ovc = function()
+
  Space.Log("value changed")
+
  end
+
Space.Host.ExecutingObject.UIInputField.OnValueChanged(ovc)</pre>|6=<pre>--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)]
+
--(example: character counter)
+
 
+
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)</pre>}}
+
 
+
 
+
=Properties=
+
 
+
{{ScriptFunction|char|AsteriskChar|{ get; set; }|The character used for password fields.|5= <pre>Space.Host.ExecutingObject.UIInputField.AsteriskChar= "%"</pre>}}
+
 
+
{{ScriptFunction|float|CaretBlinkRate|{ get; set; }|The blinking rate of the input caret, defined as the number of times the blink cycle occurs per second.|5= <pre>Space.Host.ExecutingObject.UIInputField.CaretBlinkRate= 3</pre>}}
+
 
+
{{ScriptFunction|int|CaretPosition|{ get; set; }|Current InputField caret position (also selection tail).|5= <pre>Space.Host.ExecutingObject.UIInputField.CaretPosition= 3</pre>}}
+
 
+
{{ScriptFunction|int|CaretWidth|{ get; set; }|The width of the caret in pixels.|5= <pre>Space.Host.ExecutingObject.UIInputField.CaretWidth= 4</pre>}}
+
 
+
{{ScriptFunction|int|CharacterLimit|{ get; set; }|How many characters the input field is limited to. 0 = infinite.|5= <pre>Space.Host.ExecutingObject.UIInputField.CharacterLimit= 8</pre>}}
+
 
+
{{ScriptFunction|bool|Enabled|{ get; set; }|Whether this Input Field component is Enabled or not|5= <pre>Space.Host.ExecutingObject.UIInputField.Enabled= true</pre>|6=<pre>--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)</pre>}}
+
 
+
{{ScriptFunction|bool|Interactable|{ get; set; }|Is the Input Field interactable?|5= <pre>Space.Host.ExecutingObject.UIInputField.Interactable= true</pre>"6=<pre>--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)</pre>}}
+
 
+
{{ScriptFunction|bool|IsFocused|{ get;}|Does the InputField currently have focus and is able to process events.|5= <pre>hasFocus = Space.Host.ExecutingObject.UIInputField.IsFocused </pre>}}
+
 
+
{{ScriptFunction|bool|ReadOnly|{ get;set; }|Set the InputField to be read only.|5= <pre>Space.Host.ExecutingObject.UIInputField.ReadOnly= true</pre>|6=<pre>--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)</pre>}}
+
 
+
{{ScriptFunction|int|SelectionAnchorPosition|{ get;set;}|The beginning point of the selection.|5= <pre>Space.Host.ExecutingObject.UIInputField.SelectionAnchorPosition= 1</pre>}}
+
 
+
{{ScriptFunction|int|SelectionFocusPosition|{ get;set; }|The end point of the selection.|5= <pre>Space.Host.ExecutingObject.UIInputField.SelectionFocusPosition= 4</pre>}}
+
 
+
{{ScriptFunction|string|Text|{ get;set; }|The current value of the input field.|5= <pre>Space.Host.ExecutingObject.UIInputField.Text= "Hello"</pre>|6=<pre>--the below script makes this object set Browser URL according to what's written in text field
+
--(Example: Set URL button)
+
--[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)  </pre>}}
+
 
+
{{ScriptFunction|float|FlexibleHeight|{ get;}|The extra relative height this UIInputField should be allocated if there is additional available space. (Used by the Layout system) |5= <pre>flexHeight = Space.Host.ExecutingObject.UIInputField.FlexibleHeight</pre>}}
+
 
+
{{ScriptFunction|float|FlexibleWidth|{ get;}|The extra relative width this UIInputField  should be allocated if there is additional available space. (Used by the Layout system)|5= <pre>flexWidth = Space.Host.ExecutingObject.UIInputField.FlexibleWidth</pre>}}
+
 
+
{{ScriptFunction|float|MinHeight|{ get;}|The minimum height this UIInputField may be allocated.(Used by the Layout system).|5= <pre>minHeight = Space.Host.ExecutingObject.UIInputField.MinHeight</pre>}}
+
 
+
{{ScriptFunction|float|MinWidth|{ get;}|The minimum width this UIInputField may be allocated. (Used by the Layout system).|5= <pre>minWidth = Space.Host.ExecutingObject.UIInputField.MinWidth</pre>}}
+
 
+
{{ScriptFunction|bool|MultiLine|{ get;}|If the input field supports multiple lines.|5= <pre>Space.Host.ExecutingObject.UIInputField.MultiLine = true</pre>}}
+
 
+
{{ScriptFunction|float|PreferredHeight|{ get;}|The preferred height this UIInputField should be allocated if there is sufficient space. (Used by the Layout system)|5= <pre>prefHeight = Space.Host.ExecutingObject.UIInputField.PreferredHeight</pre>}}
+
 
+
{{ScriptFunction|bool|PreferredWidth|{ get; }|The preferred width this UIInputField should be allocated if there is sufficient space. (Used by the Layout system)|5= <pre>prefWidth = Space.Host.ExecutingObject.UIInputField.PreferredWidth</pre>}}
+
 
+
 
+
{{ScriptFunction|SColor|NormalColor|{get;set}|The normal color.|5=
+
local inputField=Space.Host.GetReference("InputField").UIInputField<br>
+
Space.Log(inputField.NormalColor.ToString())
+
}}
+
 
+
{{ScriptFunction|SColor|HighlightedColor|{get;set}|The color of the control when it is highlighted.|5=
+
local inputField=Space.Host.GetReference("InputField").UIInputField<br>
+
Space.Log(inputField.HighlightedColor.ToString())
+
}}
+
 
+
{{ScriptFunction|SColor|PressedColor|{get;set}|The color of the control when it is pressed.|5=
+
local inputField=Space.Host.GetReference("InputField").UIInputField<br>
+
Space.Log(inputField.PressedColor.ToString())
+
}}
+
 
+
{{ScriptFunction|SColor|DisabledColor|{get;set}|The color of the control when it is disabled.|5=
+
local inputField=Space.Host.GetReference("InputField").UIInputField<br>
+
Space.Log(inputField.DisabledColor.ToString())
+
}}
+
 
+
{{ScriptFunction|float|ColorMultiplier|{get;set}|This multiplies the tint color for each transition by its value.|5=
+
local inputField=Space.Host.GetReference("InputField").UIInputField<br>
+
Space.Log(inputField.ColorMultiplier)
+
}}
+
 
+
 
+
{{Scripting Navbox}}
+

Latest revision as of 06:35, 19 September 2022

This page has moved to: https://docs.sine.space/v/scripting/client-scripting/components/suiinputfield