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<PointerCaptureComponent.PointerCaptureState>,
    inputListener: Consumer<InputEvent>
)

Creates a new instance of PointerCaptureComponent.

Public functions

open Boolean
onAttach(entity: Entity)

Called by the framework when this component is being added to an Entity.

open Unit
onDetach(entity: Entity)

Called by the framework when this component is being removed from an Entity.

Public companion functions

create

Added in 1.0.0-alpha14
fun create(
    session: Session,
    executor: Executor,
    stateListener: Consumer<PointerCaptureComponent.PointerCaptureState>,
    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<PointerCaptureComponent.PointerCaptureState>

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

open fun onAttach(entity: Entity): Boolean

Called by the framework when this component is being added to an Entity.

This method is triggered when Entity.addComponent is invoked. It should not be called directly by applications. Implementations should override this method to perform setup logic or to validate if the component is compatible with the provided entity.

Parameters
entity: Entity

The Entity to which this component is being attached.

Returns
Boolean

true if the component was successfully attached; false if the entity does not support this component or if attachment failed.

onDetach

open fun onDetach(entity: Entity): Unit

Called by the framework when this component is being removed from an Entity.

This method is triggered when Entity.removeComponent is invoked. It should not be called directly by applications. Implementations should override this method to release resources or undo any changes made during onAttach.

Parameters
entity: Entity

The Entity from which this component is being detached.