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 OnlyButtonHighlightModel.InteractionEnabled:
BoolValue
IsSelected
This item is read only and cannot be modified. Read OnlyButtonHighlightModel.IsSelected:
BoolValue
IsMouseOrTouchOver
This item is read only and cannot be modified. Read OnlyButtonHighlightModel.IsMouseOrTouchOver:
BoolValue
IsChoosen
This item is read only and cannot be modified. Read OnlyButtonHighlightModel.IsChoosen:
BoolValue
IsHighlighted
This item is read only and cannot be modified. Read OnlyButtonHighlightModel.IsHighlighted:
BoolValue
IsPressed
This item is read only and cannot be modified. Read OnlyButtonHighlightModel.IsPressed:
BoolValue
Functions
new
A model that dictates the current state of a button.
SetButton
Sets the button for the highlight model.
ObservePercentPressed
Observes how pressed down the button is
ObservePercentHighlighted
Observes how highlighted the button is
ObservePercentHighlightedTarget
Observes target for how highlighted the button is
ObservePercentChoosen
Observes how choosen the button is
IsInteractionEnabled
ButtonHighlightModel:
IsInteractionEnabled
(
) →
booloean
Observes interaction enabled
SetKeyDown
ButtonHighlightModel:
SetKeyDown
(
isKeyDown:
boolean
) →
(
)
Sets whether a key is down
SetInteractionEnabled
ButtonHighlightModel:
SetInteractionEnabled
(
interactionEnabled:
boolean
) →
(
)
Sets whether interaction is enabled
SetIsChoosen
ButtonHighlightModel:
SetIsChoosen
(
isChoosen:
boolean
) →
(
)
Sets whether the model is choosen