Skip to content
SiteEmail

FCohtmlInputPreprocessor

Inherits from IInputProcessor

Name
using ECohtmlGamepadBehaviourOnFocusLostEGamepadBehaviour
Name
FCohtmlInputPreprocessor()
virtual~FCohtmlInputPreprocessor()
virtual voidTick(const float DeltaTime, FSlateApplication & SlateApp, TSharedRef< ICursor > Cursor)
virtual boolHandleKeyDownEvent(FSlateApplication & SlateApp, const FKeyEvent & InKeyEvent) override
virtual boolHandleKeyUpEvent(FSlateApplication & SlateApp, const FKeyEvent & InKeyEvent) override
virtual boolHandleAnalogInputEvent(FSlateApplication & SlateApp, const FAnalogInputEvent & InAnalogInputEvent) override
virtual boolHandleMouseMoveEvent(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent) override
virtual boolHandleMouseButtonDownEvent(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent) override
virtual boolHandleMouseButtonUpEvent(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent) override
virtual boolHandleMouseButtonDoubleClickEvent(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent) override
virtual boolHandleMouseWheelOrGestureEvent(FSlateApplication & SlateApp, const FPointerEvent & InWheelEvent, const FPointerEvent * InGestureEvent) override
virtual boolHandleMotionDetectedEvent(FSlateApplication & SlateApp, const FMotionEvent & MotionEvent) override
virtual boolHandleMouseEvent(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent, cohtml::MouseEventData::EventType EventType)
virtual boolShouldHandleInput()
virtual boolShouldDiscardMouseData(FCohtmlInputWorldData & WorldData)
virtual boolGetWorldData(FCohtmlInputWorldData & WorldData)
virtual cohtml::MouseEventDataGetCoherentMouseData(const FPointerEvent & MouseEvent, cohtml::MouseEventData::EventType EventType)
virtual FVector2DGetScaledWindowPosition(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent, FCohtmlInputWorldData & WorldData)
virtual TOptional< FSceneViewProjectionData >GetProjectionData(APlayerController * PlayerController)
virtual FReplyHandleHUDInput(FVector2D ConstrainedPos, UCohtmlBaseComponent * Component, cohtml::MouseEventData & CoherentMouseData, const FPointerEvent & MouseEvent)
virtual FReplyHandleInWorldInput(UCohtmlBaseComponent * Component, COHERENT_FLOAT_FVECTOR2 & UV, cohtml::MouseEventData & CoherentMouseData, const FPointerEvent & MouseEvent)
virtual FReplyTryForwardInWorldInput(const FCohtmlInputWorldData & WorldData, FVector2D ViewportPositionVec2D, TOptional< FSceneViewProjectionData > ProjectionData, cohtml::MouseEventData & CoherentMouseData, const FPointerEvent & MouseEvent)
virtual FReplyTryForwardHUDInput(UWorld * World, FVector2D ViewportPositionVec2D, TOptional< FSceneViewProjectionData > ProjectionData, cohtml::MouseEventData & CoherentMouseData, const FPointerEvent & MouseEvent)
virtual FReplyTryForwardUMGInput(FSlateApplication & SlateApp, const FPointerEvent & MouseEvent)
virtual FReplyDiscardViewFocus(cohtml::MouseEventData::EventType EventType, const FPointerEvent & MouseEvent)
virtual voidRefocusView(UCohtmlBaseComponent * NewFocusedView, const FPointerEvent & MouseEvent =FPointerEvent())
virtual boolShouldPropagateKeyInput(const FKeyEvent & KeyEvent)
virtual voidProcessKeyEvent(const FInputEvent & Event, cohtml::KeyEventData::EventType Type)
virtual voidOnFocusReceived(const FPointerEvent & MouseEvent)
virtual voidOnFocusLost(const FPointerEvent & MouseEvent)
Name
EGamepadBehaviourGamepadBehaviourOnFocusLost
boolbShouldPropagateInput
boolbReceivesInput
boolbPropagateInputToUMG
TWeakObjectPtr< UCohtmlBaseComponent >FocusedComponent
TUniquePtr< FCohtmlInputPreprocessorIME >IMEManager
using FCohtmlInputPreprocessor::EGamepadBehaviour = ECohtmlGamepadBehaviourOnFocusLost;
FCohtmlInputPreprocessor()
inline virtual ~FCohtmlInputPreprocessor()
inline virtual void Tick(
const float DeltaTime,
FSlateApplication & SlateApp,
TSharedRef< ICursor > Cursor
)
virtual bool HandleKeyDownEvent(
FSlateApplication & SlateApp,
const FKeyEvent & InKeyEvent
) override

Key down input

virtual bool HandleKeyUpEvent(
FSlateApplication & SlateApp,
const FKeyEvent & InKeyEvent
) override

Key up input

virtual bool HandleAnalogInputEvent(
FSlateApplication & SlateApp,
const FAnalogInputEvent & InAnalogInputEvent
) override

Analog axis input

virtual bool HandleMouseMoveEvent(
FSlateApplication & SlateApp,
const FPointerEvent & MouseEvent
) override

Mouse movement input

virtual bool HandleMouseButtonDownEvent(
FSlateApplication & SlateApp,
const FPointerEvent & MouseEvent
) override

Mouse button press

virtual bool HandleMouseButtonUpEvent(
FSlateApplication & SlateApp,
const FPointerEvent & MouseEvent
) override

Mouse button release

function HandleMouseButtonDoubleClickEvent

Section titled “function HandleMouseButtonDoubleClickEvent”
virtual bool HandleMouseButtonDoubleClickEvent(
FSlateApplication & SlateApp,
const FPointerEvent & MouseEvent
) override

Mouse button double clicked.

virtual bool HandleMouseWheelOrGestureEvent(
FSlateApplication & SlateApp,
const FPointerEvent & InWheelEvent,
const FPointerEvent * InGestureEvent
) override

Mouse wheel input

virtual bool HandleMotionDetectedEvent(
FSlateApplication & SlateApp,
const FMotionEvent & MotionEvent
) override

Called when a motion-driven device has new input

virtual bool HandleMouseEvent(
FSlateApplication & SlateApp,
const FPointerEvent & MouseEvent,
cohtml::MouseEventData::EventType EventType
)

The root method for all mouse-related event handling. Should return false if it is unable to handle the event, so that it can be passed to UE4.

virtual bool ShouldHandleInput()

Decides if a given input should be handled at all - can be used to skip event forwarding entirely, for example when the game window is minimized or there is no active UI in the game

virtual bool ShouldDiscardMouseData(
FCohtmlInputWorldData & WorldData
)

Some of the mouse data passing through the InputPreprocessor is not relevant to the UI, for example mouse events over buttons in the editor in PIE. You can use this method to leave such events to Unreal Engine to handle by returning true.

virtual bool GetWorldData(
FCohtmlInputWorldData & WorldData
)

Parameters:

  • WorldData - An out parameter to fill with the data

Return: Should return false to signal that the data is unable to be obtained, for example due to the game world still initializing.

Returns the basic engine data (world, controler, etc.) needed for event forwarding

virtual cohtml::MouseEventData GetCoherentMouseData(
const FPointerEvent & MouseEvent,
cohtml::MouseEventData::EventType EventType
)

Parameters:

  • MouseEvent - The current UE4 mouse event

Return: A cohtml::MouseEventData representation of the current event

Transforms a UE4 event into a Cohtml mouse event. Some of the event properties might get changed later on during processing, but you can use this to fill in the most trivial ones via a simple mapping

virtual FVector2D GetScaledWindowPosition(
FSlateApplication & SlateApp,
const FPointerEvent & MouseEvent,
FCohtmlInputWorldData & WorldData
)

Return: A scaled representation of the current event coordinates

Scales the coordinates of the current UE4 event to local window coordinates, possibly scaled for DPI, letterboxing, etc.

virtual TOptional< FSceneViewProjectionData > GetProjectionData(
APlayerController * PlayerController
)

Return: A (possibly empty) projection data

Gets the projection data, which might be used later on during forwarding. Can be empty, for example if the viewport of player character are invalid.

virtual FReply HandleHUDInput(
FVector2D ConstrainedPos,
UCohtmlBaseComponent * Component,
cohtml::MouseEventData & CoherentMouseData,
const FPointerEvent & MouseEvent
)

Parameters:

  • ConstrainedPos - The event coordinates inside the constrained window view.
  • Component - The component which holds the view.
  • CoherentMouseData - The current event that would be sent to Cohtml.
  • MouseEvent - The original UE4 event that this HUD is handling.

Return: FReply that signifies if the event was handled or not.

Called for every HUD view found during forwarding

virtual FReply HandleInWorldInput(
UCohtmlBaseComponent * Component,
COHERENT_FLOAT_FVECTOR2 & UV,
cohtml::MouseEventData & CoherentMouseData,
const FPointerEvent & MouseEvent
)

Parameters:

  • Component - The component which holds the view.
  • UV - The hit UV coordinates.
  • CoherentMouseData - The current event that would be sent to Cohtml.
  • MouseEvent - The original UE4 event that this HUD is handling.

Return: FReply that signifies if the event was handled or not.

Called for every in-world Gameface component found during forwarding

virtual FReply TryForwardInWorldInput(
const FCohtmlInputWorldData & WorldData,
FVector2D ViewportPositionVec2D,
TOptional< FSceneViewProjectionData > ProjectionData,
cohtml::MouseEventData & CoherentMouseData,
const FPointerEvent & MouseEvent
)
virtual FReply TryForwardHUDInput(
UWorld * World,
FVector2D ViewportPositionVec2D,
TOptional< FSceneViewProjectionData > ProjectionData,
cohtml::MouseEventData & CoherentMouseData,
const FPointerEvent & MouseEvent
)
virtual FReply TryForwardUMGInput(
FSlateApplication & SlateApp,
const FPointerEvent & MouseEvent
)
virtual FReply DiscardViewFocus(
cohtml::MouseEventData::EventType EventType,
const FPointerEvent & MouseEvent
)

Parameters:

  • EventType the type of the pointer event

Return: Whether or not we will handle the event.

Called during error states or when we have reason to believe that we might have to release the input focus back to the engine.

virtual void RefocusView(
UCohtmlBaseComponent * NewFocusedView,
const FPointerEvent & MouseEvent =FPointerEvent()
)

Parameters:

  • NewFocusedView the Component which holds the view.

Called when a new view should become the focused one.

virtual bool ShouldPropagateKeyInput(
const FKeyEvent & KeyEvent
)

Parameters:

  • KeyEvent - The event currently being handled

Return: Should return true if we want to propagate the event to the engine.

Called at the end of keyboard/gamepad input handling, to determine whether or not we will forward the event to the game. Will be called regardless of whether or not any Cohtml view handled the event.

virtual void ProcessKeyEvent(
const FInputEvent & Event,
cohtml::KeyEventData::EventType Type
)

Parameters:

  • Event - The UE4 event currently being handled
  • Type - The type of the event

Called on every key event to process it. This mainly consists of just forwarding the input to the currently focused component, if any.

virtual void OnFocusReceived(
const FPointerEvent & MouseEvent
)

Parameters:

  • MouseEvent - The event that caused the focus to change.

Called when the focus switches from the Game to the UI

virtual void OnFocusLost(
const FPointerEvent & MouseEvent
)

Parameters:

  • MouseEvent - The event that caused the focus to change.

Called when the focus switches from the UI to the Game.

EGamepadBehaviour GamepadBehaviourOnFocusLost = EGamepadBehaviour::CohtmlResetState;
bool bShouldPropagateInput = true;
bool bReceivesInput = true;
bool bPropagateInputToUMG = false;
TWeakObjectPtr< UCohtmlBaseComponent > FocusedComponent;
TUniquePtr< FCohtmlInputPreprocessorIME > IMEManager;