# cp.ui.TextField

Text Field Module.


# Submodules


# API Overview

Functions - API calls offered directly by the extension

  • matches

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

  • convertingGet
  • convertingSet
  • value

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

  • clear
  • doConfirm
  • doFocus
  • forceFocus
  • getValue
  • loadLayout
  • saveLayout
  • setValue
  • TextField

# API Documentation

# Functions

# matches

Signature cp.ui.TextField.matches(element[, subrole]) -> boolean
Type Function
Description Checks 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
Notes None
Examples None
Source src/extensions/cp/ui/TextField.lua line 85

# Fields

# convertingGet

Signature cp.ui.TextField:convertingGet(getter) -> cp.ui.TextField.Builder
Type Field
Description Creates 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.
Source src/extensions/cp/ui/TextField.lua line 52

# convertingSet

Signature cp.ui.TextField:convertingSet(setter) -> cp.ui.TextField.Builder
Type Field
Description Creates 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.
Source src/extensions/cp/ui/TextField.lua line 66

# value

Signature cp.ui.TextField.value <cp.prop: string>
Type Field
Description The current value of the text field.
Notes None
Source src/extensions/cp/ui/TextField.lua line 131

# Methods

# clear

Signature cp.ui.TextField:clear() -> self
Type Method
Description Clears the value of a Text Field.
Parameters
  • None
Returns
  • Self
Notes None
Examples None
Source src/extensions/cp/ui/TextField.lua line 204

# doConfirm

Signature cp.ui.TextField:doConfirm() -> cp.rx.go.Statement
Type Method
Description A Statement that will confirm the current text value.
Parameters
  • None
Returns
  • A Statement
Notes None
Examples None
Source src/extensions/cp/ui/TextField.lua line 218

# doFocus

Signature cp.ui.TextField:doFocus() -> cp.rx.go.Statement
Type Method
Description A Statement that will attempt to focus on the current TextField.
Parameters
  • None
Returns
  • A Statement
Notes None
Examples None
Source src/extensions/cp/ui/TextField.lua line 237

# forceFocus

Signature cp.ui.TextField:forceFocus()
Type Method
Description Configures 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
Notes None
Examples None
Source src/extensions/cp/ui/TextField.lua line 163

# getValue

Signature cp.ui.TextField:getValue() -> string
Type Method
Description Gets the value of the Text Field.
Parameters
  • None
Returns
  • The value of the Text Field as a string.
Notes None
Examples None
Source src/extensions/cp/ui/TextField.lua line 177

# loadLayout

Signature cp.ui.TextField:loadLayout(layout) -> none
Type Method
Description Loads a Text Field layout.
Parameters
  • layout - A table containing the Text Field layout settings - created using cp.ui.TextField:saveLayout().
Returns
  • None
Notes None
Examples None
Source src/extensions/cp/ui/TextField.lua line 271

# saveLayout

Signature cp.ui.TextField:saveLayout() -> table
Type Method
Description Saves the current Text Field layout to a table.
Parameters
  • None
Returns
  • A table containing the current Text Field Layout.
Notes None
Examples None
Source src/extensions/cp/ui/TextField.lua line 256

# setValue

Signature cp.ui.TextField:setValue(value) -> self
Type Method
Description Sets the value of the Text Field.
Parameters
  • value - The value you want to set the Text Field to as a string.
Returns
  • Self
Notes None
Examples None
Source src/extensions/cp/ui/TextField.lua line 190

# TextField

Signature cp.ui.TextField(parent, uiFinder, getConvertFn, setConvertFn) -> TextField
Type Method
Description Creates 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>
Examples None
Source src/extensions/cp/ui/TextField.lua line 100