Skip to main content

ButtonHighlightModel

Contains model information for the current button.

Usage with Blend!

function Button.new()
	local self = setmetatable(BaseObject.new(), Button)

	-- Store the button model in the actual button so we can ensure it cleans up
	-- this assumes only one render. We can also construct it in the Button.Render

	self._buttonModel = ButtonHighlightModel.new()
	self._maid:GiveTask(self._buttonModel)

	return self
end

function Button:Render()
	...
	return Blend.New "ImageButton" {
		...
		[Blend.Instance] = function(button)
			self._buttonModel:SetButton(button)
		end;
		BackgroundTransparency = Blend.Computed(self._buttonModel:ObservePercentPressed(), function(pressed)
			return 1 - pressed
		end);
	}
end

Properties

InteractionEnabled

This item is read only and cannot be modified. Read Only
ButtonHighlightModel.InteractionEnabled: BoolValue

IsSelected

This item is read only and cannot be modified. Read Only
ButtonHighlightModel.IsSelected: BoolValue

IsMouseOrTouchOver

This item is read only and cannot be modified. Read Only
ButtonHighlightModel.IsMouseOrTouchOver: BoolValue

IsChoosen

This item is read only and cannot be modified. Read Only
ButtonHighlightModel.IsChoosen: BoolValue

IsHighlighted

This item is read only and cannot be modified. Read Only
ButtonHighlightModel.IsHighlighted: BoolValue

IsPressed

This item is read only and cannot be modified. Read Only
ButtonHighlightModel.IsPressed: BoolValue

Functions

new

ButtonHighlightModel.new(
button?GuiBase,
onUpdatefunction?
) → ButtonHighlightModel

A model that dictates the current state of a button.

SetButton

ButtonHighlightModel:SetButton(buttonInstance) → ()

Sets the button for the highlight model.

ObservePercentPressed

ButtonHighlightModel:ObservePercentPressed() → Observable<number>

Observes how pressed down the button is

ObservePercentHighlighted

ButtonHighlightModel:ObservePercentHighlighted() → Observable<number>

Observes how highlighted the button is

ObservePercentHighlightedTarget

ButtonHighlightModel:ObservePercentHighlightedTarget() → Observable<number>

Observes target for how highlighted the button is

ObservePercentChoosen

ButtonHighlightModel:ObservePercentChoosen() → Observable<number>

Observes how choosen the button is

IsInteractionEnabled

ButtonHighlightModel:IsInteractionEnabled() → booloean

Observes interaction enabled

SetKeyDown

ButtonHighlightModel:SetKeyDown(isKeyDownboolean) → ()

Sets whether a key is down

SetInteractionEnabled

ButtonHighlightModel:SetInteractionEnabled(interactionEnabledboolean) → ()

Sets whether interaction is enabled

SetIsChoosen

ButtonHighlightModel:SetIsChoosen(isChoosenboolean) → ()

Sets whether the model is choosen

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "A model that dictates the current state of a button.",
            "params": [
                {
                    "name": "button?",
                    "desc": "",
                    "lua_type": "GuiBase"
                },
                {
                    "name": "onUpdate",
                    "desc": "",
                    "lua_type": "function?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ButtonHighlightModel"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 55,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "SetButton",
            "desc": "Sets the button for the highlight model.",
            "params": [
                {
                    "name": "button",
                    "desc": "",
                    "lua_type": "Instance"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 198,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "ObservePercentPressed",
            "desc": "Observes how pressed down the button is",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<number>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 248,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "ObservePercentHighlighted",
            "desc": "Observes how highlighted the button is",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<number>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 261,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "ObservePercentHighlightedTarget",
            "desc": "Observes target for how highlighted the button is",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<number>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 269,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "ObservePercentChoosen",
            "desc": "Observes how choosen the button is",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<number>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 282,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "IsInteractionEnabled",
            "desc": "Observes interaction enabled",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "booloean"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 295,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "SetKeyDown",
            "desc": "Sets whether a key is down",
            "params": [
                {
                    "name": "isKeyDown",
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 303,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "SetInteractionEnabled",
            "desc": "Sets whether interaction is enabled",
            "params": [
                {
                    "name": "interactionEnabled",
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 311,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "SetIsChoosen",
            "desc": "Sets whether the model is choosen",
            "params": [
                {
                    "name": "isChoosen",
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 321,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "InteractionEnabled",
            "desc": "",
            "lua_type": "BoolValue",
            "readonly": true,
            "source": {
                "line": 65,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "IsSelected",
            "desc": "",
            "lua_type": "BoolValue",
            "readonly": true,
            "source": {
                "line": 74,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "IsMouseOrTouchOver",
            "desc": "",
            "lua_type": "BoolValue",
            "readonly": true,
            "source": {
                "line": 83,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "IsChoosen",
            "desc": "",
            "lua_type": "BoolValue",
            "readonly": true,
            "source": {
                "line": 100,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "IsHighlighted",
            "desc": "",
            "lua_type": "BoolValue",
            "readonly": true,
            "source": {
                "line": 117,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        },
        {
            "name": "IsPressed",
            "desc": "",
            "lua_type": "BoolValue",
            "readonly": true,
            "source": {
                "line": 126,
                "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
            }
        }
    ],
    "types": [],
    "name": "ButtonHighlightModel",
    "desc": "Contains model information for the current button.\n\nUsage with Blend!\n\n```lua\nfunction Button.new()\n\tlocal self = setmetatable(BaseObject.new(), Button)\n\n\t-- Store the button model in the actual button so we can ensure it cleans up\n\t-- this assumes only one render. We can also construct it in the Button.Render\n\n\tself._buttonModel = ButtonHighlightModel.new()\n\tself._maid:GiveTask(self._buttonModel)\n\n\treturn self\nend\n\nfunction Button:Render()\n\t...\n\treturn Blend.New \"ImageButton\" {\n\t\t...\n\t\t[Blend.Instance] = function(button)\n\t\t\tself._buttonModel:SetButton(button)\n\t\tend;\n\t\tBackgroundTransparency = Blend.Computed(self._buttonModel:ObservePercentPressed(), function(pressed)\n\t\t\treturn 1 - pressed\n\t\tend);\n\t}\nend\n```",
    "source": {
        "line": 35,
        "path": "src/buttonhighlightmodel/src/Client/ButtonHighlightModel.lua"
    }
}