Widget Reference

Buttons

Values


text

The text displayed on the Button. Required. (string)

Scripts


on_click = function(self, mouseButton, down)

Run when the Button is clicked.

Arguments

  • self - Reference to the Button for which the script was run. (frame)

  • mouseButton - Name of the mouse button responsible for the click action. (string)

    • Button4
    • Button5
    • LeftButton
    • MiddleButton
    • RightButton
  • down - True for a mouse button down action; false for button up or other actions. (boolean)

Example

    LibDialog:Register("ButtonExample", {
    	buttons = {
    		{
    			text = "This is a button.",
    			on_click = function(self, mouseButton, down)
    				print("You clicked a button.")
    			end,
    		},
    		{
    			text = "This is a second button."
    			on_click = function(self, mouseButton, down)
    				print("You clicked a second button.")
    			end,
    		},
    	},        	
    })

CheckBoxes

Values


label

The CheckBox label. Required. (string)

Scripts


on_click = function(self, mouseButton, down)

Run when the CheckBox is clicked.

Arguments

  • self - Reference to the CheckBox for which the script was run. (frame)

  • mouseButton - Name of the mouse button responsible for the click action. (string)

    • Button4
    • Button5
    • LeftButton
    • MiddleButton
    • RightButton
  • down - True for a mouse button down action; false for button up or other actions. (boolean)

Example

    LibDialog:Register("CheckBoxExample", {
    	checkboxes = {
    		{
    			label = "Yes, I want ice cream.",
    			on_click = function(self, mouseButton, down)
    				print("It's cold.")
    			end,
    		},
    		{
    			label = "No, I do not want cat food."
    			on_click = function(self, mouseButton, down)
    				print("Meow.")
    			end,
    		},
    	},        	
    })

EditBoxes

Values


auto_focus

Sets whether the EditBox automatically acquires keyboard input focus. (boolean)

label

The EditBox label. (string)

max_bytes

Sets the maximum number of bytes of text allowed in the EditBox. Attempts to type more than this number into the EditBox will produce no results; programmatically inserting text or setting the EditBox's text will truncate input to the maximum length. (number)

Omitting this value, or setting it to 0, results in no limit.

Note: Unicode characters may consist of more than one byte each, so the behavior of a byte limit may differ from that of a character limit in practical use.

max_letters

Sets the maximum number of text characters allowed in the EditBox. Attempts to type more than this number into the EditBox will produce no results; programmatically inserting text or setting the EditBox's text will truncate input to the maximum length. (number)

Omitting this value, or setting it to 0, results in no limit.

text

Initial text of the EditBox. (string)

width

Width for the EditBox (in pixels); if 0, causes the EditBox's width to be determined automatically according to its anchor points. (number)

Scripts


on_enter_pressed = function(self)

Run when the Enter (or Return) key is pressed while the EditBox has keyboard focus.

Arguments

  • self - Reference to the EditBox for which the script was run. (frame)

on_escape_pressed = function(self)

Run when the Escape key is pressed while the EditBox has keyboard focus.

Arguments

  • self - Reference to the EditBox for which the script was run. (frame)

on_show = function(self)

Run when the EditBox becomes visible.

Arguments

  • self - Reference to the EditBox for which the script was run. (frame)

on_text_changed = function(self, userInput)

Run when the EditBox's text is changed. This script is run both when text is typed in the EditBox (for each character entered) and when the EditBox's contents are changed via :SetText() (but only if the text is actually changed).

Arguments

  • self - Reference to the EditBox for which the script was run. (frame)

  • userInput - True if the text changed due to user input; false if the text was changed via :SetText() (boolean)

Example

    LibDialog:Register("EditBoxExample", {
        editboxes = {
		{
			on_enter_pressed = function(self)
				print("Enter pressed.")
				Dialog:Dismiss("EditBoxExample")
			end,
			on_escape_pressed = function(self)
				print("Escape pressed.")
				Dialog:Dismiss("EditBoxExample")
			end,
			on_show = function(self)
				self:SetText("Yay!")
			end,
			auto_focus = true,
			label = "Enter your nickname",
			max_letters = 128,
			text = "My initial text!",
			width = 200,
		},
	})