Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ImageButton

A UI button.

Hierarchy

Index

Properties

onClicked

onClicked: MulticastDelegate<(button: this, player: Player) => void>

Called when the button is clicked.

param

The button that was clicked

param

The player who clicked the button

Methods

getImageFileHeight

  • getImageFileHeight(): number
  • Get the height of the displayed image file. Does not have to be identical to the desired height of the image, use getImageHeight for that. Returns 0 if no texture has been set.

    Returns number

getImageFileWidth

  • getImageFileWidth(): number
  • Get the width of the displayed image file. Does not have to be identical to the desired width of the image, use getImageWidth for that. Returns 0 if no texture has been set.

    Returns number

getImageHeight

  • getImageHeight(): number

getImageWidth

  • getImageWidth(): number

getOwningObject

getParent

  • getParent(): Widget | undefined
  • Return the widget that contains this widget, for example a border that wraps a check box. Returns undefined if this object has no parent.

    Returns Widget | undefined

isEnabled

  • isEnabled(): boolean

setEnabled

  • setEnabled(enabled: boolean): Widget
  • Set whether the widget is enabled. When a widget is disabled, users can't interact with it and it is greyed out. When a widget that contains other widgets (like VerticalBox) is disabled, all its children behave as if disabled, too. By default, widgets are enabled.

    Parameters

    • enabled: boolean

      Whether to enable the widget.

    Returns Widget

setImage

  • setImage(textureName: string, packageId?: string): ImageButton
  • Set the displayed image file from a package.

    Parameters

    • textureName: string

      The filename of the image to load

    • Optional packageId: string

      The id of the package that contains the image file (in the texture folder). Can be empty when used from scripts to use the same package that contains the script file (same as passing refPackageId). You can find package ids in the manifest.json file in package folders. Usually you won't use this parameter, unless you a specific reason to load an image from a different package than where the script is located.

    Returns ImageButton

setImageSize

  • setImageSize(width: number, height: number): ImageButton
  • Set the desired size of the image. If both axes are set to 0, the size will be the actual size of the image file. If only one axis is set to 0, it will be set to a value that preserves the aspect ratio of the image, and the other value above 0 will be fixed. Desired size can get overridden by the widget size on a Canvas or the size of the UIElement when the image is the only widget and UIElement.useWidgetSize is false. The button has two pixels of padding around the image on all sides, so the total size of the button will be four pixels larger on each axis.

    Parameters

    • width: number

      Desired width of the image. Default: 0

    • height: number

      Desired height of the image. Default: 0

    Returns ImageButton

setImageURL

  • Set the displayed image file from a URL

    Parameters

    • url: string

      The filename of the image to load

    Returns ImageButton