Skip to main content

EventManager

APJS Script API reference for the EventManager namespace.

TypeNameInterface Description
Static FunctionscreateEvent(eventType: number | UserEventType): IEvent

Function: Creates and returns a new event instance based on the provided event type.

Parameters

eventType: - The type of the event, which can be either a numeric code or a predefined UserEventType enum value.

Returns An IEvent object representing the created event.

Static FunctionsdefineUserEventType(eventName: number | string): UserEventType

Function: Defines a user-defined event type. This method allows you to create and register a custom event type with a unique identifier, which can be used to trigger and handle events in your application.

Parameters

eventName: - The unique identifier for the user event type. Can be either a number or a string.

Returns The newly defined or existing UserEventType associated with the provided identifier.

Static FunctionsgetGestureEmitter(): IEventEmitter

Function: Retrieves the event emitter associated with gesture.

Returns The event emitter for the gesture, which can be used to subscribe to gesture events defined in GestureType.

Static FunctionsgetGlobalEmitter(): IEventEmitter

Function: Retrieves the global event emitter instance. If it doesn't exist, it creates a new one.

Returns The global event emitter instance.

Static FunctionsgetObjectEmitter(obj: AObject): IEventEmitter

Function: Retrieves the event emitter associated with a given object.

Parameters

obj: - The object for which to get the event emitter. This can be an AObject.

Returns The event emitter for the specified object. Returns undefined only when the input object is invalid or not supported.

Examples

createEvent(eventType: number | UserEventType): IEvent

const event = APJS.EventManager.createEvent(myEventType);

defineUserEventType(eventName: number | string): UserEventType

const USER_EVENT_01: UserEventType = APJS.EventManager.defineUserEventType(42);
const USER_EVENT_02: UserEventType = APJS.EventManager.defineUserEventType('foo');

getGestureEmitter(): IEventEmitter

const emitter = APJS.EventManager.getGestureEmitter();
const callback = (event:APJS.IEvent) => {
const gestureInfo = event.args[0] as APJS.GestureInfo;
const offset = gestureInfo.endPoint.clone().subtract(gestureInfo.startPoint);
// Do something with drag offset
}
emitter.on(GestureType.Drag, callback)

getGlobalEmitter(): IEventEmitter

const emitter = APJS.EventManager.getGlobalEmitter();
emitter.emit(myEvent);

getObjectEmitter(obj: AObject): IEventEmitter

const emitter = APJS.EventManager.getObjectEmitter(myObject);
emitter.emit(myEvent);

Use Case

@component()
export class NewBehaviourScript extends APJS.BasicScriptComponent {
onStart() {
// TODO: instantiate / use EventManager here
}
onUpdate(deltaTime: number) {
}
}
Copyright © 2026 TikTok. All rights reserved.
About TikTokHelp CenterCareersContactLegalTerms of ServicePrivacy PolicyCookies