PointerCaptureComponent


class PointerCaptureComponent : Component


Provides pointer capture capabilities for a given Entity.

To enable pointer capture, the task must be in full space, the entity must be visible, and the PointerCaptureComponent must be attached to the entity.

Only one PointerCaptureComponent can be attached to an entity at a given time. If a second one tries to attach to an entity, it will fail.

Summary

Nested types

Defines the possible states of a PointerCaptureComponent.

Public companion functions

PointerCaptureComponent
create(
    session: Session,
    executor: Executor,
    stateListener: Consumer<Int>,
    inputListener: Consumer<InputEvent>
)

Creates a new instance of PointerCaptureComponent.

Public functions

open Boolean
onAttach(entity: Entity)

Called by an Entity when it attempts to add this Component to itself.

open Unit
onDetach(entity: Entity)

Called by an Entity when it attempts to detach this Component from itself.

Public companion functions

create

Added in 1.0.0-alpha05
fun create(
    session: Session,
    executor: Executor,
    stateListener: Consumer<Int>,
    inputListener: Consumer<InputEvent>
): PointerCaptureComponent

Creates a new instance of PointerCaptureComponent.

Parameters
session: Session

The active Session for the scene.

executor: Executor

The Executor on which the listener callbacks will be invoked.

stateListener: Consumer<Int>

A Consumer to receive updates when the pointer capture state changes (e.g., from active to paused).

inputListener: Consumer<InputEvent>

A Consumer to receive all InputEvents while pointer capture is active for the attached entity.

Public functions

onAttach

Added in 1.0.0-alpha05
open fun onAttach(entity: Entity): Boolean

Called by an Entity when it attempts to add this Component to itself.

This method is restricted because it is only called from Entity.addComponent.

Parameters
entity: Entity

Entity to which this Component was attached.

Returns
Boolean

True if the Component was attached to the given Entity. False if the Entity did not support having this Component attached.

onDetach

Added in 1.0.0-alpha05
open fun onDetach(entity: Entity): Unit

Called by an Entity when it attempts to detach this Component from itself.

This method is restricted because it is only called from Entity.removeComponent.

Parameters
entity: Entity

Entity from which this Component was detached.