Skip to content
Aaron H edited this page Dec 10, 2016 · 2 revisions

Information

The image button object is pretty much the same as the button object except it can have an image.

Example Use

local frame = loveframes.Create("frame")
frame:SetName("Image Button")
frame:SetSize(138, 163)
frame:CenterWithinArea(unpack(demo.centerarea))
         
local imagebutton = loveframes.Create("imagebutton", frame)
imagebutton:SetImage("resources/images/carlsagan.png")
imagebutton:SetPos(5, 30)
imagebutton:SizeToImage()

Event Callbacks

OnClick

Called every time the object is clicked

Arguments passed: self [object], mouse x [number], mouse y [number]

local imagebutton = loveframes.Create("imagebutton")
imagebutton.OnClick = function(object)
    print("The image button was clicked!")
end

Methods

SetText

Sets the object's text

object:SetText(text[string])

GetText

Gets the object's text

Returns 1 value: text [string]

local text = object:GetText()

SetClickable

Sets whether or not the object is clickable

object:SetClickable(clickable[bool])

GetClickable

Gets whether or not the object is clickable

Returns 1 value: clickable [boolean]

local clickable = object:GetClickable()
``

## SetEnabled
Sets whether or not the object is enabled

```lua
object:SetEnabled(enabled[bool])

GetEnabled

Gets whether or not the object is enabled

Returns 1 value: enabled [bool]

local enabled = object:GetEnabled()

SetImage

Sets the object's image

imagebutton:SetImage(image[string (imagepath) or imageobject])

GetImage

Gets the object's image

Returns 1 value: image [image]

local image = imagebutton:GetImage()

SizeToImage

Makes the object the size of it's image

imagebutton:SizeToImage()

GetImageSize

Gets the object's image size

Returns 2 values: imagewidth [number], imageheight [number]

local imagewidth, imageheight = object:GetImageSize()

GetImageWidth

Gets the object's image width

Returns 1 value: imagewidth [number]

local imagewidth = object:GetImageWidth()

GetImageHeight

Gets the object's image height

Returns 1 value: imageheight [number]

local imageheight = object:GetImageHeight()