Skip to content

Callback Guide

Peter Robinson edited this page Aug 18, 2026 · 2 revisions

Introduction

Callbacks are scripting "hooks" that the engine provides, which allow you to write custom responses to events. Callbacks are optional, if the engine fires off a callback and nothing is defined for that event, then nothing happens.

A common callback that is used in many types of games is "onCollision". When the physics system registers a contact between two objects that have their collision properties properly defined and at least one of the objects has its callback turned on, you can define a script reponse for this event like so:

function SceneObject::onCollision(%this, %sceneObject, %collisionDetails)
{
}

Depending on the namespace and what the object inherits from, you can define callbacks at the name, class/superclass, behavior, or object level.

Callback List

Remember that the amount of callbacks available to an object depends on its inheritance tree. A Sprite, for example, is not listed here but has the callbacks available from SpriteBase, SceneObject, and SimObject.

Game Objects

SimObject

  • onAdd
  • onRemove

CompositeSprite

  • onCustomLayout

ParticlePlayer

  • onStopParticlePlayer

SceneObject

  • onUpdate
  • onWake
  • onSleep
  • onMoveToComplete
  • onRotateToComplete
  • onFadeToComplete
  • onGrowToComplete

Trigger

  • onEnter
  • onStay
  • onLeave

SpriteBase

  • onAnimationEnd

Scene

  • onSceneCollision
  • onCollision
  • onSceneEndCollision
  • onEndCollision
  • onSceneUpdate
  • onSceneRender
  • onAddToScene
  • onRemoveFromScene
  • onSafeDelete

Behaviors

BehaviorComponent

  • onBehaviorAdd
  • onBehaviorRemove
  • onBehaviorMissing

SimComponent

  • onComponentAdd
  • onComponentRemove

GUI

SceneWindow

  • onExtentChange

GuiCheckBoxCtrl

  • onClick

GuiSceneObjectCtrl

  • onDoubleClick
  • onMouseEnter
  • onMouseLeave
  • onMouseDragged

GuiTabBookCtrl

  • onTabSelected

GuiEditCtrl

  • onClearSelected
  • onAddSelected
  • onAddNewCtrl
  • onPreEdit
  • onPostEdit
  • onSelect
  • onSelectionParentChange
  • onPreSelectionNudged
  • onPostSelectionNudged
  • onSelectionMoved
  • onTrashSelection
  • onDelete
  • onControlInspectPreApply
  • onControlInspectPostApply

GuiMenuBarCtrl

  • onAddMenuItem
  • onOpen
  • onClose

GuiCanvas

  • onWake

GuiControl

  • onWake
  • onSleep
  • onAction
  • onDialogPush
  • onDialogPop

GuiInputCtrl

  • onInputEvent

GuiListBoxCtrl

  • onUnselect
  • onSelect
  • onMouseDragged
  • onDoubleClick

GuiMessageVectorCtrl

  • urlClickCallback

GuiSliderCtrl

  • onMouseDragged

GuiTextEditCtrl

  • onMouseDown
  • onMouseDragged
  • onMouseUp
  • onTab
  • onValidate
  • onReturn
  • onLoseFirstResponder

GuiTreeViewCtrl

  • onClick
  • onDoubleClick
  • onGetItemIcon
  • onGetObjectText
  • onPreReorder
  • onPostReorder

Modules

ModuleManager

  • onModuleRegister
  • onModulePreLoad
  • onModulePostLoad
  • onModulePreUnload
  • onModulePostUnload

Platform

PopupMenu

  • onMessageReceived

GameCenter

  • onAdd
  • onRemove
  • gameCenterAuthenticationChanged

main

  • oniOSResignActive
  • oniOSBecomeActive
  • oniOSWillTerminate
  • onExit
  • oniOSOrientationToLandscapeLeft
  • oniOSOrientationToLandscapeRight
  • oniOSOrientationToPortrait
  • oniOSOrientationToPortraitUpsideDown

Network

GameConnection

  • onConnectionAccepted
  • onConnectRequestTimedOut
  • onConnectionDropped
  • onConnectRequestRejected
  • onConnectionError
  • onDrop
  • setLagIcon

ServerQuery

  • onServerQueryStatus
  • onClearGameTypes
  • onAddGameType
  • onClearMissionTypes
  • onAddMissionType

Miscellaneous

UndoManager

  • onClear
  • onRemoveUndo
  • onUndo
  • onRedo
  • onAddUndo

ScriptMsgListener

  • onMessageReceived
  • onMessageObjectReceived
  • onAddToQueue
  • onRemoveFromQueue

Clone this wiki locally