UInputBehavior

An InputBehavior implements a state machine for a user interaction.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

InteractiveToolsFramework

Header

/Engine/Source/Runtime/Experimental/InteractiveToolsFramework/Public/InputBehavior.h

Include

#include "InputBehavior.h"

Syntax

class UInputBehavior : public UObject

Remarks

An InputBehavior implements a state machine for a user interaction. The InputRouter maintains a set of active Behaviors, and when new input events occur, it calls WantsCapture() to check if the Behavior would like to begin capturing the applicable input event stream (eg for a mouse, one or both VR controllers, etc). If the Behavior acquires capture, UpdateCapture() is called until the Behavior indicates that it wants to release the device, or until the InputRouter force-terminates the capture via ForceEndCapture().

For example, something like ButtonSetClickBehavior might work as follows:

  • in WantsCapture(), if left mouse is pressed and a button is under cursor, return Begin, otherwise Ignore

  • in BeginCapture(), save identifier for button that is under cursor

  • in UpdateCapture()

  • if left mouse is down, return Continue

  • if left mouse is released:

  • if saved button is still under cursor, call button.Clicked()

  • return End

Written sufficiently generically, the above Behavior doesn't need to know about buttons, it just needs to know how to hit-test the clickable object(s). Similarly separate Behaviors can be written for mouse, VR, touch, gamepad, etc.

Implementing interactions in this way allows the input handling to be separated from functionality.

Variables

Name Description

Protected variable

FInputCapturePr...

 

DefaultPriority

Priority returned by GetPriority()

Constructors

Name Description

Public function

UInputBehavior()

Functions

Name Description

Public function Virtual

FInputCaptur...

 

BeginCapture

(
    const FInputDeviceState& InputStat...,
    EInputCaptureSide eSide
)

Called after WantsCapture() returns a capture request that was accepted

Public function Virtual

FInputCaptur...

 

BeginHoverCapture

(
    const FInputDeviceState& InputStat...,
    EInputCaptureSide eSide
)

Called after WantsHoverCapture() returns a capture request that was accepted

Public function Virtual

void

 

EndHoverCapture()

If a different hover capture begins, focus is lost, a tool starts, etc, any active hover visualization needs to terminate

Public function Virtual

void

 

ForceEndCapture

(
    const FInputCaptureData& CaptureDa...
)

If this is called, the Behavior has forcibly lost capture (eg due to app losing focus for example) and needs to clean up accordingly

Public function Virtual

FInputCaptur...

 

GetPriority()

The priority is used to resolve situations where multiple behaviors want the same capture

Public function Virtual

EInputDevice...

 

GetSupportedDevices()

Which device types does this Behavior support

Public function Virtual

void

 

SetDefaultPriority

(
    const FInputCapturePriority& Prior...
)

Configure the default priority of an instance of this behavior

Public function Virtual

FInputCaptur...

 

UpdateCapture

(
    const FInputDeviceState& InputStat...,
    const FInputCaptureData& CaptureDa...
)

Called for each new input event during a capture sequence.

Public function Virtual

FInputCaptur...

 

UpdateHoverCapture

(
    const FInputDeviceState& InputStat...
)

Called on each new hover input event, ie if no other behavior is actively capturing input

Public function Virtual

FInputCaptur...

 

WantsCapture

(
    const FInputDeviceState& InputStat...
)

Given the input state, does this Behavior want to begin capturing some input devices?

Public function Virtual

FInputCaptur...

 

WantsHoverCapture

(
    const FInputDeviceState& InputStat...
)

Given the input state, does this Behavior want to begin capturing some input devices for hover

Public function Virtual

bool

 

WantsHoverEvents()

Hover support (optional)return true if this Behavior supports hover (ie passive input events)

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