-
Notifications
You must be signed in to change notification settings - Fork 2
Text Boxes
To create a new Textbox call:
local myTextBox = ErumiUILib.Textbox.CreateTextbox(screen, {
Name = "Keyboard1",
Group = "Combat_Menu",
X = 900,
Y = 500,
Scale = {X = 1, Y = 0.44},
BackgroundColor = {0.5, 0.5, 0.5, 1},
TextStyle = {
FontSize = 10,
Color = {0.988, 0.792, 0.247, 1},
Width = 470,
Justification = "Left",
Offset = {X = -235, Y = -60},
},
ValidityStyle = {
FontSize = 7,
Colors = {
Unknown = {0.988, 0.792, 0.247, 1},
Valid = {1,1,1,1},
Invalid = {1,0,0,1},
},
Width = 470,
Justification = "Left",
Offset = {X = -235, Y = -90},
},
CheckValidOnUpdate = true,
CheckFunc = function(text)
if RandomChance( 0.5 ) then
return true, "This isn't even shown"
else
return nil, "The input you have entered is incorrect. Please reassess your (life)choices"
end
end,
ShowCursor = true,
CursorColor = {1,0,0,1},
CursorSpacing = 10,
OnFocus = function (textbox)
ErumiUILib.Keyboard.Expand(myKeyboard)
end,
MaxLength = 7,
})
This will create a new Textbox and myTextbox will be the object that is created.
Field Name | Type | Description |
---|---|---|
Name | String | The name of the Textbox having a unique name is better |
Group | String | The group of UI elements that the new UI elements will be created in |
X | Int | The X position of the base of the textbox |
Y | Int | The Y position of the base of the textbox |
StartingText | String | The text that starts in the textbox |
Scale | Table(ints only) | The scale of the base of the textbox, X is the X scale, and Y is the Y scale |
BackgroundColor | Color | The color of the background of the textbox |
TextStyle | Table(see below) | The formatting for the text inside the textbox |
ValidityStyle | Table (same as text style but with 3 colors) | The formatting for the validity message(see info below) |
CheckValidOnUpdate | bool | If true runs check every time the Textfield is updated |
CheckFunc | Function | The function run when the Textfield checks the internal text |
ShowCursor | Bool | The default value for showing a cursor or not, true show the cursor, false don't |
CursorColor | Color | The color of the cursor |
CursorSpacing | Int | The space from one character to the cursor |
OnFocus | Function(textbox object) | Runs the function when the textbox is clicked on, is passed the textbox object that is being clicked on |
MaxLength | Int | The max amount of characters allowed in the textbox, if nil defaults to 999999 |
Field Name | Type | Description |
---|---|---|
FontSize | Int | The size of the font inside the textbox |
Color | Color | The color of the text |
Width | Int | The width of the textbox displaying the text inside the input field |
Justification | Justification | Left, Center, or Right like normal justifications |
Offset | Table(ints only) | The offset of the text from the center of the textbox |
Used so modders can check if the string format is valid when input into the textbox. CheckValidity can be used to manually activate this (through a button) or CheckValidOnUpdate will check the validity every time the Textfield is updated. CheckFunc must always return like so:
return state, message
state must either be true or nil. If true then the textbox is considered valid (and a variable .isValid in the textbox object will be set to true). This will hide the validity text, message is disregarded in this case. If nil then the textbox will be considered invalid(and a variable .isValid in the textbox object will be set to false). When invalid the validity textbox will appear (using the ValidityStyle table). Its color will be the invalid color in the validity style. If message is not nil the validity style textbox will display the message (meanign if it is nil nothing will appear but an internal bool will still be set). If CheckFunc is nil then .isValid will be set to nil as well (showing unchecked). The validity textbox will also disappear.
To call any function type ErumiUILib.Textbox.FunctionName(Arguments)
Function Name | Arguments | Description |
---|---|---|
Update | Textfield Object, string | Sets the textbox's current text to the string (Will not update the cursor position) |
Write | Textfield Object, string | Inserts the string into the textbox's text at the cursor position |
Delete | Textfield Object, Int | Deletes the number of characters equal to the passed in int starting from the cursor and going left |
SetCursorPosition | Textfield Object, int | Sets the Textbox's cursor position to the passed in int |
GetText | Textfield Object | returns a string of the textbox's current text |
SetText | Textfield Object, string | Sets the passd in textbox's text to the passed in string and sets the cursor position to the end |
ShowCursor | Textfield Object, bool | Shows or hides cursor depending on bool ,if true show cursor, if false don't show cursor |
Destroy | A Textfield Object | Destroys the Textfield and all children components |
CheckValidity | A Textfield Object | Runs CheckFunc then modifies the validity text accordingly |