SButton

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

Choose your operating system:

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().

Constructors

Name Description

Protected function

SButton()

Functions

Name Description

Public function

void

 

Construct

(
    const FArguments& InArgs
)

Construct this widget

Protected function

void

 

ExecuteHoverStateChanged

(
    bool bPlaySound
)

Protected function

FReply

 

ExecuteOnClick()

Execute the "OnClicked" delegate, and get the reply

Protected function Const

TSlateAttrib...

 

GetAppearPressedAttribute()

Protected function Const

TSlateAttrib...

 

GetBorderForegroundColorAttribute()

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

TSlateAttrib...

 

GetContentPaddingAttribute()

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 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

Protected function

void

 

SetAppearPressed

(
    TAttribute< bool > InValue
)

Set the AppearPressed look.

Public function

void

 

SetButtonStyle

(
    const FButtonStyle* ButtonStyl...
)

See ButtonStyle attribute

Public function

void

 

SetClickMethod

(
    EButtonClickMethod::Type InClickMet...
)

Public function

void

 

SetContentPadding

(
    TAttribute< FMargin > InContentPadd...
)

See ContentPadding attribute

Public function

void

 

SetHoveredSound

(
    TOptional< FSlateSound > InHoveredS...
)

See HoveredSound attribute

Protected function

void

 

SetIsFocusable

(
    bool bInIsFocusable
)

Set if this button can be focused

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...
)

Public function

void

 

SimulateClick()

Public function Static

const FSlate...

 

StaticWidgetClass()

Overridden from SWidget

Name Description

Public function Virtual

TSharedRef< ...

 

CreateAccessibleWidget()

Public function Virtual Const

FSlateColor

 

GetDisabledForegroundColor()

Public function Virtual Const

FSlateColor

 

GetForegroundColor()

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.

Overridden from FSlateControlledConstruction

Name Description

Public function Virtual Const

const FSlate...

 

GetWidgetClass()

Classes

Name

Description

Public struct

FArguments

Typedefs

Deprecated Variables

Name Description

Protected variable

FMargin

 

BorderPadding

BorderPadding is now deprecated. Use the ButtonStyle.

Protected variable

TSlateDeprecate...

 

ContentPadding

Direct access to ContentPadding is now deprecated. Use the setter or getter.

Protected variable

const FSlateBru...

 

DisabledImage

DisabledImage is now deprecated. Use the ButtonStyle.

Protected variable

const FSlateBru...

 

HoverImage

HoverImage is now deprecated. Use the ButtonStyle.

Protected variable

const FSlateBru...

 

NormalImage

NormalImage is now deprecated. Use the ButtonStyle.

Protected variable

FMargin

 

PressedBorderPadding

PressedBorderPadding is now deprecated. Use the ButtonStyle.

Protected variable

const FSlateBru...

 

PressedImage

PressedImage is now deprecated. Use the ButtonStyle.

Deprecated Functions

Name Description

Public function Virtual Const

const FSlate...

 

GetBorder()

GetBorder is deprecated. Use SetBorderImage or GetBorderImage