UWidgetInteractionComponent

This is a component to allow interaction with the Widget Component.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

UMG

Header

/Engine/Source/Runtime/UMG/Public/Components/WidgetInteractionComponent.h

Include

#include "Components/WidgetInteractionComponent.h"

Syntax

class UWidgetInteractionComponent : public USceneComponent

Remarks

This is a component to allow interaction with the Widget Component. This class allows you to simulate a sort of laser pointer device, when it hovers over widgets it will send the basic signals to show as if the mouse were moving on top of it. You'll then tell the component to simulate key presses, like Left Mouse, down and up, to simulate a mouse click.

Variables

Name Description

Public variable

bool

 

bEnableHitTesting

Should the interaction component perform hit testing (Automatic or Custom) and attempt to simulate hover - if you were going to emulate a keyboard you would want to turn this option off if the virtual keyboard was separate from the virtual pointer device and used a second interaction component.

Protected variable

bool

 

bIsHoveredWidgetFocusable

Are we hovering over any focusable widget?

Protected variable

bool

 

bIsHoveredWidgetHitTestVisible

Are we hovered over a widget that is hit test visible?

Protected variable

bool

 

bIsHoveredWidgetInteractable

Are we hovering over any interactive widgets.

Public variable

bool

 

bShowDebug

Shows some debugging lines and a hit sphere to help you debug interactions.

Protected variable

FHitResult

 

CustomHitResult

Stores the custom hit result set by the player.

Public variable

FLinearColor

 

DebugColor

Determines the color of the debug lines.

Public variable

float

 

DebugLineThickness

Determines the thickness of the debug lines.

Public variable

float

 

DebugSphereLineThickness

Determines the line thickness of the debug sphere.

Protected variable

UWidgetComponen...

 

HoveredWidgetComponent

The widget component we're currently hovering over.

Public variable

float

 

InteractionDistance

The distance in game units the component should be able to interact with a widget component.

Public variable

EWidgetInteract...

 

InteractionSource

Should we project from the world location of the component? If you set this to false, you'll need to call SetCustomHitResult(), and provide the result of a custom hit test form whatever location you wish.

Protected variable

FHitResult

 

LastHitResult

The last hit result we used.

Protected variable

FVector2D

 

LastLocalHitLocation

The last 2D location on the widget component that was hit.

Protected variable

FWeakWidgetPath

 

LastWidgetPath

The last widget path under the hit result.

Protected variable

FVector2D

 

LocalHitLocation

The 2D location on the widget component that was hit.

Protected variable

FModifierKeysSt...

 

ModifierKeys

The modifier keys to simulate during key presses.

Public variable

FOnHoveredWidge...

 

OnHoveredWidgetChanged

Called when the hovered Widget Component changes.

Public variable

int32

 

PointerIndex

Each user virtual controller or virtual finger tips being simulated should use a different pointer index.

Protected variable

TSet< FKey >

 

PressedKeys

The current set of pressed keys we maintain the state of.

Public variable

TEnumAsByte< EC...

 

TraceChannel

The trace channel to use when tracing for widget components in the world.

Protected variable

TSharedPtr< FSl...

 

VirtualUser

Represents the virtual user in slate.

Public variable

int32

 

VirtualUserIndex

Represents the Virtual User Index.

Constructors

Name Description

Public function

UWidgetInteractionComponent

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Protected function Const

bool

 

CanInteractWithComponent

(
    UWidgetComponent* Component
)

Returns true if the inteaction component can interact with the supplied widget component

Protected function

bool

 

CanSendInput()

Is it safe for this interaction component to run? Might not be in a server situation with no slate application.

Protected function Virtual Const

FWidgetPath

 

FindHoveredWidgetPath

(
    const FWidgetTraceResult& TraceRes...
)

Gets the WidgetPath for the widget being hovered over based on the hit result.

Public function Const

FVector2D

 

Get2DHitLocation()

Gets the last hit location on the widget in 2D, local pixel units of the render target.

Public function Const

UWidgetCompo...

 

GetHoveredWidgetComponent()

Get the currently hovered widget component.

Public function Const

const FWeakW...

 

GetHoveredWidgetPath()

Gets the widget path for the slate widgets under the last hit result.

Protected function

void

 

GetKeyAndCharCodes

(
    const FKey& Key,
    bool& bHasKeyCode,
    uint32& KeyCode,
    bool& bHasCharCode,
    uint32& CharCode
)

Gets the key and char codes for sending keys for the platform.

Public function Const

const FHitRe...

 

GetLastHitResult()

Gets the last hit result generated by the component. Returns the custom hit result if that was set.

Protected function Const

void

 

GetRelatedComponentsToIgnoreInAutomaticHitTesting

(
    TArray< UPrimitiveComponent* >...
)

Gets the list of components to ignore during hit testing.

Public function Const

bool

 

IsOverFocusableWidget()

Returns true if a widget under the hit result is focusable.

Public function Const

bool

 

IsOverHitTestVisibleWidget()

Returns true if a widget under the hit result is has a visibility that makes it hit test visible.

Public function Const

bool

 

IsOverInteractableWidget()

Returns true if a widget under the hit result is interactive.

Protected function Virtual Const

FWidgetTrace...

 

PerformTrace()

Performs the trace and gets the hit result under the specified InteractionSource

Public function Virtual

bool

 

PressAndReleaseKey

(
    FKey Key
)

Does both the press and release of a simulated keyboard key.

Public function Virtual

bool

 

PressKey

(
    FKey Key,
    bool bRepeat
)

Press a key as if it had come from the keyboard.

Public function Virtual

void

 

PressPointerKey

(
    FKey Key
)

Presses a key as if the mouse/pointer were the source of it.

Public function Virtual

bool

 

ReleaseKey

(
    FKey Key
)

Releases a key as if it had been released by the keyboard.

Public function Virtual

void

 

ReleasePointerKey

(
    FKey Key
)

Releases a key as if the mouse/pointer were the source of it.

Public function Virtual

void

 

ScrollWheel

(
    float ScrollDelta
)

Sends a scroll wheel event to the widget under the last hit result.

Public function Virtual

bool

 

SendKeyChar

(
    FString Characters,
    bool bRepeat
)

Transmits a list of characters to a widget by simulating a OnKeyChar event for each key listed in the string.

Public function

void

 

SetCustomHitResult

(
    const FHitResult& HitResult
)

Set custom hit result.

Public function

void

 

SetFocus

(
    UWidget* FocusWidget
)

Set the focus target of the virtual user managed by this component

Protected function

void

 

SimulatePointerMovement()

Performs the simulation of pointer movement. Does not run if bEnableHitTesting is set to false.

Overridden from UActorComponent

Name Description

Public function Virtual

void

 

Activate

(
    bool bReset
)

Activates the SceneComponent, should be overridden by native child classes.

Public function Virtual

void

 

Deactivate()

Deactivates the SceneComponent.

Public function Virtual

void

 

OnComponentCreated()

Called when a component is created (not loaded). This can happen in the editor or during gameplay

Public function Virtual

void

 

TickComponent

(
    float DeltaTime,
    enum ELevelTick TickType,
    FActorComponentTickFunction* T...
)

Function called every frame on this ActorComponent.

Classes

Name

Description

Protected struct

FWidgetTraceResult

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss