NGUI: Next-Gen UI kit  3.7.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros
UIInput Class Reference

Input field makes it possible to enter custom information within the UI. More...

Inheritance diagram for UIInput:

Public Types

enum  InputType { InputType.Standard, InputType.AutoCorrect, InputType.Password }
 
enum  Validation {
  Validation.None, Validation.Integer, Validation.Float, Validation.Alphanumeric,
  Validation.Username, Validation.Name
}
 
enum  KeyboardType {
  KeyboardType.Default = 0, KeyboardType.ASCIICapable = 1, KeyboardType.NumbersAndPunctuation = 2, KeyboardType.URL = 3,
  KeyboardType.NumberPad = 4, KeyboardType.PhonePad = 5, KeyboardType.NamePhonePad = 6, KeyboardType.EmailAddress = 7
}
 
enum  OnReturnKey { OnReturnKey.Default, OnReturnKey.Submit, OnReturnKey.NewLine }
 

Public Member Functions

delegate char OnValidate (string text, int charIndex, char addedChar)
 
string Validate (string val)
 Validate the specified text, returning the validated version. More...
 
void Submit ()
 Submit the input field's text. More...
 
void UpdateLabel ()
 Update the visual text label. More...
 
void RemoveFocus ()
 Convenience function to be used as a callback that will clear the input field's focus. More...
 
void SaveValue ()
 Convenience function that can be used as a callback for On Change notification. More...
 
void LoadValue ()
 Convenience function that can forcefully reset the input field's value to what was saved earlier. More...
 

Public Attributes

UILabel label
 Text label used to display the input's value. More...
 
InputType inputType = InputType.Standard
 Type of data expected by the input field. More...
 
OnReturnKey onReturnKey = OnReturnKey.Default
 What to do when the Return key is pressed on the keyboard. More...
 
KeyboardType keyboardType = KeyboardType.Default
 Keyboard type applies to mobile keyboards that get shown. More...
 
bool hideInput = false
 Whether the input will be hidden on mobile platforms. More...
 
Validation validation = Validation.None
 What kind of validation to use with the input field's data. More...
 
int characterLimit = 0
 Maximum number of characters allowed before input no longer works. More...
 
string savedAs
 Field in player prefs used to automatically save the value. More...
 
GameObject selectOnTab
 Object to select when Tab key gets pressed. More...
 
Color activeTextColor = Color.white
 Color of the label when the input field has focus. More...
 
Color caretColor = new Color(1f, 1f, 1f, 0.8f)
 Color used by the caret symbol. More...
 
Color selectionColor = new Color(1f, 223f / 255f, 141f / 255f, 0.5f)
 Color used by the selection rectangle. More...
 
List< EventDelegateonSubmit = new List<EventDelegate>()
 Event delegates triggered when the input field submits its data. More...
 
List< EventDelegateonChange = new List<EventDelegate>()
 Event delegates triggered when the input field's text changes for any reason. More...
 
OnValidate onValidate
 Custom validation callback. More...
 

Static Public Attributes

static UIInput current
 Currently active input field. Only valid during callbacks. More...
 
static UIInput selection
 Currently selected input field, if any. More...
 

Protected Member Functions

void Init ()
 Labels used for input shouldn't support rich text. More...
 
void SaveToPlayerPrefs (string val)
 Save the specified value to player prefs. More...
 
virtual void OnSelect (bool isSelected)
 Selection event, sent by the EventSystem. More...
 
void OnSelectEvent ()
 Notification of the input field gaining selection. More...
 
void OnDeselectEvent ()
 Notification of the input field losing selection. More...
 
void DoBackspace ()
 Perform a backspace operation. More...
 
virtual bool ProcessEvent (Event ev)
 Handle the specified event. More...
 
virtual void Insert (string text)
 Insert the specified text string into the current input value, respecting selection and validation. More...
 
string GetLeftText ()
 Get the text to the left of the selection. More...
 
string GetRightText ()
 Get the text to the right of the selection. More...
 
string GetSelection ()
 Get currently selected text. More...
 
int GetCharUnderMouse ()
 Helper function that retrieves the index of the character under the mouse. More...
 
virtual void OnPress (bool isPressed)
 Move the caret on press. More...
 
virtual void OnDrag (Vector2 delta)
 Drag selection. More...
 
virtual void Cleanup ()
 Cleanup. More...
 
void SetPivotToLeft ()
 Set the label's pivot to the left. More...
 
void SetPivotToRight ()
 Set the label's pivot to the right. More...
 
void RestoreLabelPivot ()
 Restore the input label's pivot point. More...
 
char Validate (string text, int pos, char ch)
 Validate the specified input. More...
 
void ExecuteOnChange ()
 Execute the OnChange callback. More...
 

Protected Attributes

string mValue
 Input field's value. More...
 
string mDefaultText = ""
 
Color mDefaultColor = Color.white
 
float mPosition = 0f
 
bool mDoInit = true
 
UIWidget.Pivot mPivot = UIWidget.Pivot.TopLeft
 
bool mLoadSavedValue = true
 
int mSelectionStart = 0
 
int mSelectionEnd = 0
 
UITexture mHighlight = null
 
UITexture mCaret = null
 
Texture2D mBlankTex = null
 
float mNextBlink = 0f
 
float mLastAlpha = 0f
 
string mCached = ""
 
int mSelectMe = -1
 

Static Protected Attributes

static int mDrawStart = 0
 
static string mLastIME = ""
 

Properties

string defaultText [get, set]
 Default text used by the input's label. More...
 
bool inputShouldBeHidden [get]
 Should the input be hidden? More...
 
string text [get, set]
 
string value [get, set]
 Input field's current text value. More...
 
bool selected [get, set]
 
bool isSelected [get, set]
 Whether the input is currently selected. More...
 
int cursorPosition [get, set]
 Current position of the cursor. More...
 
int selectionStart [get, set]
 Index of the character where selection begins. More...
 
int selectionEnd [get, set]
 Index of the character where selection ends. More...
 
UITexture caret [get]
 Caret, in case it's needed. More...
 

Detailed Description

Input field makes it possible to enter custom information within the UI.

Member Enumeration Documentation

Enumerator
Standard 
AutoCorrect 
Password 
Enumerator
Default 
ASCIICapable 
NumbersAndPunctuation 
URL 
NumberPad 
PhonePad 
NamePhonePad 
EmailAddress 
Enumerator
Default 
Submit 
NewLine 
Enumerator
None 
Integer 
Float 
Alphanumeric 
Username 
Name 

Member Function Documentation

virtual void UIInput.Cleanup ( )
protectedvirtual

Cleanup.

void UIInput.DoBackspace ( )
protected

Perform a backspace operation.

void UIInput.ExecuteOnChange ( )
protected

Execute the OnChange callback.

int UIInput.GetCharUnderMouse ( )
protected

Helper function that retrieves the index of the character under the mouse.

string UIInput.GetLeftText ( )
protected

Get the text to the left of the selection.

string UIInput.GetRightText ( )
protected

Get the text to the right of the selection.

string UIInput.GetSelection ( )
protected

Get currently selected text.

void UIInput.Init ( )
protected

Labels used for input shouldn't support rich text.

virtual void UIInput.Insert ( string  text)
protectedvirtual

Insert the specified text string into the current input value, respecting selection and validation.

void UIInput.LoadValue ( )

Convenience function that can forcefully reset the input field's value to what was saved earlier.

void UIInput.OnDeselectEvent ( )
protected

Notification of the input field losing selection.

virtual void UIInput.OnDrag ( Vector2  delta)
protectedvirtual

Drag selection.

virtual void UIInput.OnPress ( bool  isPressed)
protectedvirtual

Move the caret on press.

virtual void UIInput.OnSelect ( bool  isSelected)
protectedvirtual

Selection event, sent by the EventSystem.

void UIInput.OnSelectEvent ( )
protected

Notification of the input field gaining selection.

delegate char UIInput.OnValidate ( string  text,
int  charIndex,
char  addedChar 
)
virtual bool UIInput.ProcessEvent ( Event  ev)
protectedvirtual

Handle the specified event.

void UIInput.RemoveFocus ( )

Convenience function to be used as a callback that will clear the input field's focus.

void UIInput.RestoreLabelPivot ( )
protected

Restore the input label's pivot point.

void UIInput.SaveToPlayerPrefs ( string  val)
protected

Save the specified value to player prefs.

void UIInput.SaveValue ( )

Convenience function that can be used as a callback for On Change notification.

void UIInput.SetPivotToLeft ( )
protected

Set the label's pivot to the left.

void UIInput.SetPivotToRight ( )
protected

Set the label's pivot to the right.

void UIInput.Submit ( )

Submit the input field's text.

void UIInput.UpdateLabel ( )

Update the visual text label.

string UIInput.Validate ( string  val)

Validate the specified text, returning the validated version.

char UIInput.Validate ( string  text,
int  pos,
char  ch 
)
protected

Validate the specified input.

Member Data Documentation

Color UIInput.activeTextColor = Color.white

Color of the label when the input field has focus.

Color UIInput.caretColor = new Color(1f, 1f, 1f, 0.8f)

Color used by the caret symbol.

int UIInput.characterLimit = 0

Maximum number of characters allowed before input no longer works.

UIInput UIInput.current
static

Currently active input field. Only valid during callbacks.

bool UIInput.hideInput = false

Whether the input will be hidden on mobile platforms.

InputType UIInput.inputType = InputType.Standard

Type of data expected by the input field.

KeyboardType UIInput.keyboardType = KeyboardType.Default

Keyboard type applies to mobile keyboards that get shown.

UILabel UIInput.label

Text label used to display the input's value.

Texture2D UIInput.mBlankTex = null
protected
string UIInput.mCached = ""
protected
UITexture UIInput.mCaret = null
protected
Color UIInput.mDefaultColor = Color.white
protected
string UIInput.mDefaultText = ""
protected
bool UIInput.mDoInit = true
protected
int UIInput.mDrawStart = 0
staticprotected
UITexture UIInput.mHighlight = null
protected
float UIInput.mLastAlpha = 0f
protected
string UIInput.mLastIME = ""
staticprotected
bool UIInput.mLoadSavedValue = true
protected
float UIInput.mNextBlink = 0f
protected
UIWidget.Pivot UIInput.mPivot = UIWidget.Pivot.TopLeft
protected
float UIInput.mPosition = 0f
protected
int UIInput.mSelectionEnd = 0
protected
int UIInput.mSelectionStart = 0
protected
int UIInput.mSelectMe = -1
protected
string UIInput.mValue
protected

Input field's value.

List<EventDelegate> UIInput.onChange = new List<EventDelegate>()

Event delegates triggered when the input field's text changes for any reason.

OnReturnKey UIInput.onReturnKey = OnReturnKey.Default

What to do when the Return key is pressed on the keyboard.

List<EventDelegate> UIInput.onSubmit = new List<EventDelegate>()

Event delegates triggered when the input field submits its data.

OnValidate UIInput.onValidate

Custom validation callback.

string UIInput.savedAs

Field in player prefs used to automatically save the value.

UIInput UIInput.selection
static

Currently selected input field, if any.

Color UIInput.selectionColor = new Color(1f, 223f / 255f, 141f / 255f, 0.5f)

Color used by the selection rectangle.

GameObject UIInput.selectOnTab

Object to select when Tab key gets pressed.

Validation UIInput.validation = Validation.None

What kind of validation to use with the input field's data.

Property Documentation

UITexture UIInput.caret
get

Caret, in case it's needed.

int UIInput.cursorPosition
getset

Current position of the cursor.

string UIInput.defaultText
getset

Default text used by the input's label.

bool UIInput.inputShouldBeHidden
get

Should the input be hidden?

bool UIInput.isSelected
getset

Whether the input is currently selected.

bool UIInput.selected
getset
int UIInput.selectionEnd
getset

Index of the character where selection ends.

int UIInput.selectionStart
getset

Index of the character where selection begins.

string UIInput.text
getset
string UIInput.value
getset

Input field's current text value.


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