#cp.ui.TextField

Text Field Module.


#Submodules


#API Overview

Functions - API calls offered directly by the extension

Fields - Variables which can only be accessed from an object returned by a constructor

Methods - API calls which can only be made on an object returned by a constructor


#API Documentation

#Functions

Signaturecp.ui.TextField.matches(element[, subrole]) -> boolean
TypeFunction
DescriptionChecks to see if an element matches what we think it should be.
Parameters
  • element - An axuielementObject to check.
  • subrole - (optional) If provided, the field must have the specified subrole.
Returns
  • true if matches otherwise false
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/TextField.lua line 85

#Fields

Signaturecp.ui.TextField:convertingGet(getter) -> cp.ui.TextField.Builder
TypeField
DescriptionCreates a Builder that will convert the result of the TextField:value() getter to a different type.
Parameters
  • getter - A function that will be called to get the value from the TextField.
Returns
  • The TextField.Builder
Notes
  • The getter will be called with the string value from the TextField as its only parameter.
  • For example, TextField:convertGet(tonumber) will use the standard tonumber function to convert the value to a number.
Sourcesrc/extensions/cp/ui/TextField.lua line 52

Signaturecp.ui.TextField:convertingSet(setter) -> cp.ui.TextField.Builder
TypeField
DescriptionCreates a Builder that will convert the value before setting it in the TextField.
Parameters
  • setter - A function that will be called to set the value in the TextField.
Returns
  • The TextField.Builder
Notes
  • The setter will be called with the input value from a TextField:value(...) call as its only parameter.
  • It should return a string to be saved into the TextField.
  • For example, TextField:convertSet(tostring) will use the standard tostring function to convert the value to a string.
Sourcesrc/extensions/cp/ui/TextField.lua line 66

Signaturecp.ui.TextField.value <cp.prop: string>
TypeField
DescriptionThe current value of the text field.
NotesNone
Sourcesrc/extensions/cp/ui/TextField.lua line 131

#Methods

Signaturecp.ui.TextField:clear() -> self
TypeMethod
DescriptionClears the value of a Text Field.
Parameters
  • None
Returns
  • Self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/TextField.lua line 204

Signaturecp.ui.TextField:doConfirm() -> cp.rx.go.Statement
TypeMethod
DescriptionA Statement that will confirm the current text value.
Parameters
  • None
Returns
  • A Statement
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/TextField.lua line 218

Signaturecp.ui.TextField:doFocus() -> cp.rx.go.Statement
TypeMethod
DescriptionA Statement that will attempt to focus on the current TextField.
Parameters
  • None
Returns
  • A Statement
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/TextField.lua line 237

Signaturecp.ui.TextField:forceFocus()
TypeMethod
DescriptionConfigures the TextField to force a focus on the field before editing. Some fields seem to require this to actually update the text value.
Parameters
  • None
Returns
  • Self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/TextField.lua line 163

Signaturecp.ui.TextField:getValue() -> string
TypeMethod
DescriptionGets the value of the Text Field.
Parameters
  • None
Returns
  • The value of the Text Field as a string.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/TextField.lua line 177

Signaturecp.ui.TextField:loadLayout(layout) -> none
TypeMethod
DescriptionLoads a Text Field layout.
Parameters
  • layout - A table containing the Text Field layout settings - created using cp.ui.TextField:saveLayout().
Returns
  • None
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/TextField.lua line 271

Signaturecp.ui.TextField:saveLayout() -> table
TypeMethod
DescriptionSaves the current Text Field layout to a table.
Parameters
  • None
Returns
  • A table containing the current Text Field Layout.
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/TextField.lua line 256

Signaturecp.ui.TextField:setValue(value) -> self
TypeMethod
DescriptionSets the value of the Text Field.
Parameters
  • value - The value you want to set the Text Field to as a string.
Returns
  • Self
NotesNone
ExamplesNone
Sourcesrc/extensions/cp/ui/TextField.lua line 190

Signaturecp.ui.TextField(parent, uiFinder, getConvertFn, setConvertFn) -> TextField
TypeMethod
DescriptionCreates a new TextField. They have a parent and a finder function.
Parameters
  • parent - The parent object.
  • uiFinder - The function will return the axuielement for the TextField.
  • getConvertFn - (optional) If provided, will be passed the string value when returning.
  • setConvertFn - (optional) If provided, will be passed the number value when setting.
Returns
  • The new TextField.
Notes
  • Additionally, an optional convert function can be provided, with the following signature:
  • function(textValue) -> anything
  • The value will be passed to the function before being returned, if present. All values passed into value(x) will be converted to a string first via tostring.
  • For example, to have the value be converted into a number, simply use tonumber like this:
  • lua</li><li>local numberField = TextField(parent, function() return ... end, tonumber, tostring)</li><li>
ExamplesNone
Sourcesrc/extensions/cp/ui/TextField.lua line 100