SButton

Slate's Buttons are clickable Widgets that can contain arbitrary widgets as its [Content()](API\Developer\TargetPlatform\EProjectType).

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Slate

Header

/Engine/Source/Runtime/Slate/Public/Widgets/Input/SButton.h

Include

#include "Widgets/Input/SButton.h"

Syntax

class SButton : public SBorder

Remarks

Slate's Buttons are clickable Widgets that can contain arbitrary widgets as its Content() .

Variables

Name Description

Protected variable

uint8 : 1

 

bIsFocusable

Can this button be focused?

Protected variable

uint8 : 1

 

bIsPressed

True if this button is currently in a pressed state

Protected variable

FMargin

 

BorderPadding

Padding that accounts for the button border

Protected variable

TEnumAsByte < EB ...

 

ClickMethod

Sets whether a click should be triggered on mouse down, mouse up, or that both a mouse down and up are required.

Protected variable

TAttribute < FMa ...

 

ContentPadding

Padding specified by the user; it will be combind with the button's internal padding.

Protected variable

const FSlateBru ...

 

DisabledImage

Brush resource that represents a button when it is disabled

Protected variable

FSlateSound

 

HoveredSound

The Sound to play when the button is hovered

Protected variable

const FSlateBru ...

 

HoverImage

Brush resource that represents a button when it is hovered

Protected variable

const FSlateBru ...

 

NormalImage

Brush resource that represents a button

Protected variable

FOnClicked

 

OnClicked

The delegate to execute when the button is clicked

Protected variable

FSimpleDelegate

 

OnHovered

Protected variable

FSimpleDelegate

 

OnPressed

The delegate to execute when the button is pressed

Protected variable

FSimpleDelegate

 

OnReleased

The delegate to execute when the button is released

Protected variable

FSimpleDelegate

 

OnUnhovered

Protected variable

FMargin

 

PressedBorderPadding

Padding that accounts for the button border when pressed

Protected variable

const FSlateBru ...

 

PressedImage

Brush resource that represents a button when it is pressed

Protected variable

FVector2D

 

PressedScreenSpacePosition

The location in screenspace the button was pressed

Protected variable

FSlateSound

 

PressedSound

The Sound to play when the button is pressed

Protected variable

TEnumAsByte < EB ...

 

PressMethod

How should the button be clicked with keyboard/controller button events?

Protected variable

const FButtonSt ...

 

Style

Style resource for the button

Protected variable

TEnumAsByte < EB ...

 

TouchMethod

How should the button be clicked with touch events?

Constructors

Name Description

Public function

SButton()

Functions

Name Description

Public function

void

 

Construct

(
    const FArguments & InArgs
)

Construct this widget

Protected function

FReply

 

ExecuteOnClick()

Public function Virtual Const

const FSlate ...

 

GetBorder()

Protected function Const

TEnumAsByte <...

 

GetClickMethodFromInputType

(
    const FPointerEvent & MouseEvent
)

Utility function to translate other input click methods to regular ones.

Protected function Const

FMargin

 

GetCombinedPadding()

Protected function Const

bool

 

GetShowDisabledEffect()

Protected function Const

bool

 

IsPreciseTapOrClick

(
    const FPointerEvent & MouseEvent
)

Utility function to determine if the incoming mouse event is for a precise tap or click

Public function Virtual Const

bool

 

IsPressed()

Returns true if this button is currently pressed

Protected function Const

void

 

PlayHoverSound()

Play the hovered sound

Protected function Const

void

 

PlayPressedSound()

Play the pressed sound

Protected function Virtual

void

 

Press()

Press the button

Protected function Virtual

void

 

Release()

Release the button

Public function

void

 

SetButtonStyle

(
    const FButtonStyle * ButtonStyl...
)

See ButtonStyle attribute

Public function

void

 

SetClickMethod

(
    EButtonClickMethod::Type InClickMet...
)

Public function

void

 

SetContentPadding

(
    const TAttribute < FMargin >& InCon...
)

See ContentPadding attribute

Public function

void

 

SetHoveredSound

(
    TOptional < FSlateSound > InHoveredS...
)

See HoveredSound attribute

Public function

void

 

SetOnClicked

(
    FOnClicked InOnClicked
)

See OnClicked event

Public function

void

 

SetOnHovered

(
    FSimpleDelegate InOnHovered
)

Set OnHovered event

Public function

void

 

SetOnUnhovered

(
    FSimpleDelegate InOnUnhovered
)

Set OnUnhovered event

Public function

void

 

SetPressedSound

(
    TOptional < FSlateSound > InPressedS...
)

See PressedSound attribute

Public function

void

 

SetPressMethod

(
    EButtonPressMethod::Type InPressMet...
)

Public function

void

 

SetTouchMethod

(
    EButtonTouchMethod::Type InTouchMet...
)

Overridden from SWidget

Name Description

Public function Virtual Const

bool

 

ComputeVolatility()

Recomputes the volatility of the widget.

Public function Virtual

TSharedRef < ...

 

CreateAccessibleWidget()

Public function Virtual Const

bool

 

IsInteractable()

Public function Virtual

void

 

OnFocusLost

(
    const FFocusEvent & InFocusEvent
)

Called when this widget loses focus. This event does not bubble.

Public function Virtual

FReply

 

OnKeyDown

(
    const FGeometry & MyGeometry,
    const FKeyEvent & InKeyEvent
)

Called after a key is pressed when this widget has focus (this event bubbles if not handled)

Public function Virtual

FReply

 

OnKeyUp

(
    const FGeometry & MyGeometry,
    const FKeyEvent & InKeyEvent
)

Called after a key is released when this widget has focus

Public function Virtual

FReply

 

OnMouseButtonDoubleClick

(
    const FGeometry & InMyGeometry,
    const FPointerEvent & InMouseEvent
)

Called when a mouse button is double clicked. Override this in derived classes.

Public function Virtual

FReply

 

OnMouseButtonDown

(
    const FGeometry & MyGeometry,
    const FPointerEvent & MouseEvent
)

MOUSE INPUT The system calls this method to notify the widget that a mouse button was pressed within it.

Public function Virtual

FReply

 

OnMouseButtonUp

(
    const FGeometry & MyGeometry,
    const FPointerEvent & MouseEvent
)

The system calls this method to notify the widget that a mouse button was release within it.

Public function Virtual

void

 

OnMouseCaptureLost

(
    const FCaptureLostEvent & CaptureLo...
)

Called when this widget had captured the mouse, but that capture has been revoked for some reason.

Public function Virtual

void

 

OnMouseEnter

(
    const FGeometry & MyGeometry,
    const FPointerEvent & MouseEvent
)

The system will use this event to notify a widget that the cursor has entered it.

Public function Virtual

void

 

OnMouseLeave

(
    const FPointerEvent & MouseEvent
)

The system will use this event to notify a widget that the cursor has left it.

Public function Virtual

FReply

 

OnMouseMove

(
    const FGeometry & MyGeometry,
    const FPointerEvent & MouseEvent
)

The system calls this method to notify the widget that a mouse moved within it.

Public function Virtual Const

int32

 

OnPaint

(
    const FPaintArgs & Args,
    const FGeometry & AllottedGeometry,
    const FSlateRect & MyCullingRect,
    FSlateWindowElementList & OutDrawEl...,
    int32 LayerId,
    const FWidgetStyle & InWidgetStyle,
    bool bParentEnabled
)

The widget should respond by populating the OutDrawElements array with FDrawElements that represent it and any of its children.

Public function Virtual Const

bool

 

SupportsKeyboardFocus()

Checks to see if this widget supports keyboard focus. Override this in derived classes.

Classes

Name

Description

Public struct

FArguments

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback