PointerCaptureComponent


public final class PointerCaptureComponent implements 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 methods

static final @NonNull PointerCaptureComponent
create(
    @NonNull Session session,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull Integer> stateListener,
    @NonNull Consumer<@NonNull InputEvent> inputListener
)

Creates a new instance of PointerCaptureComponent.

boolean

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

void

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

Public methods

create

Added in 1.0.0-alpha05
public static final @NonNull PointerCaptureComponent create(
    @NonNull Session session,
    @NonNull Executor executor,
    @NonNull Consumer<@NonNull Integer> stateListener,
    @NonNull Consumer<@NonNull InputEvent> inputListener
)

Creates a new instance of PointerCaptureComponent.

Parameters
@NonNull Session session

The active Session for the scene.

@NonNull Executor executor

The Executor on which the listener callbacks will be invoked.

@NonNull Consumer<@NonNull Integer> stateListener

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

@NonNull Consumer<@NonNull InputEvent> inputListener

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

onAttach

Added in 1.0.0-alpha05
public boolean onAttach(@NonNull Entity entity)

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
@NonNull 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
public void onDetach(@NonNull Entity entity)

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
@NonNull Entity entity

Entity from which this Component was detached.