hookEvents

hookEvents

A directory listing of hook events which occur in the Foundry VTT framework

Methods

(static) applyActiveEffect(actor, change)

A hook event that fires when a custom active effect is applied.

Parameters:
Name Type Description
actor Actor

The actor the active effect is being applied to

change data.EffectChangeData

The change data being applied

(static) canvasInit(canvas)

A hook event that fires when the Canvas is initialized.

Parameters:
Name Type Description
canvas Canvas

The canvas

(static) canvasPan(canvas, transform)

A hook event that fires when the Canvas is panned.

Parameters:
Name Type Description
canvas Canvas

The canvas

transform object

The applied translate/transform

Properties
Name Type Description
x number

The constrained x-coordinate of the pan

y number

The constrained y-coordinate of the pan

scale number

The constrained zoom level of the pan

(static) canvasReady(canvas)

A hook event that fires when the Canvas is ready.

Parameters:
Name Type Description
canvas Canvas

The canvas

(static) changeSidebarTab(app)

A hook event that fires when the Sidebar tab is changed.

Parameters:
Name Type Description
app SidebarTab

The SidebarTab application which is now active

(static) chatBubble(token, html, message, options)

A hook event that fires when a chat bubble is rendered.

Parameters:
Name Type Description
token Token

The speaking token

html jQuery

The HTML of the chat bubble

message string

The spoken message text

options object
Properties
Name Type Description
emote boolean

Whether to style the speech bubble as an emote

(static) chatMessage(chatLog, message, chatData)

A hook event that fires when a user sends a message through the ChatLog.

Parameters:
Name Type Description
chatLog ChatLog

The ChatLog instance

message string

The trimmed message content

chatData object

Some basic chat data

Properties
Name Type Description
user User

The User sending the message

speaker object

The identified speaker data, see ChatMessage.getSpeaker

(static) closeApplication(app, html)

A hook event that fires whenever this Application is closed.

Parameters:
Name Type Description
app Application

The Application instance being closed

html Array.<jQuery>

The application HTML when it is closed

(static) collapseSceneNavigation(sceneNavigation, collapsed)

A hook event that fires when the SceneNavigation menu is expanded or collapsed.

Parameters:
Name Type Description
sceneNavigation SceneNavigation

The SceneNavigation application

collapsed boolean

Whether the SceneNavigation is now collapsed or not

(static) collapseSidebar(sidebar, collapsed)

A hook event that fires when the Sidebar is collapsed or expanded.

Parameters:
Name Type Description
sidebar Sidebar

The Sidebar application

collapsed boolean

Whether the Sidebar is now collapsed or not

(static) controlPlaceableObject(object, controlled)

A hook event that fires when any PlaceableObject is selected or deselected. Substitute the PlaceableObject name in the hook event to target a specific PlaceableObject type, for example "controlToken".

Parameters:
Name Type Description
object PlaceableObject

The PlaceableObject

controlled boolean

Whether the PlaceableObject is selected or not

(static) createDocument(document, options, userId)

A hook event that fires for every embedded Document type after conclusion of a creation workflow. Substitute the Document name in the hook event to target a specific type, for example "createToken". This hook fires for all connected clients after the creation has been processed.

Parameters:
Name Type Description
document Document

The new Document instance which has been created

options object

Additional options which modified the creation request

userId string

The ID of the User who triggered the creation workflow

(static) deleteDocument(document, options, userId)

A hook event that fires for every Document type after conclusion of an deletion workflow. Substitute the Document name in the hook event to target a specific Document type, for example "deleteActor". This hook fires for all connected clients after the deletion has been processed.

Parameters:
Name Type Description
document Document

The existing Document which was deleted

options object

Additional options which modified the deletion request

userId string

The ID of the User who triggered the deletion workflow

(static) dropActorSheetData(actor, sheet, data)

A hook event that fires when some useful data is dropped onto an ActorSheet.

Parameters:
Name Type Description
actor Actor

The Actor

sheet ActorSheet

The ActorSheet application

data object

The data that has been dropped onto the sheet

(static) dropCanvasData(canvas, data)

A hook event that fires when some useful data is dropped onto the Canvas.

Parameters:
Name Type Description
canvas Canvas

The Canvas

data object

The data that has been dropped onto the Canvas

(static) dropRollTableSheetData(table, sheet, data)

A hook event that fires when some useful data is dropped onto a RollTableConfig.

Parameters:
Name Type Description
table RollTable

The RollTable

sheet RollTableConfig

The RollTableConfig application

data object

The data dropped onto the RollTableConfig

(static) getApplicationHeaderButtons(app, buttons)

A hook event that fires whenever this Application is first rendered to add buttons to its header.

Parameters:
Name Type Description
app Application

The Application instance being rendered

buttons Array.<ApplicationHeaderButton>

The array of header buttons which will be displayed

(static) getPlaylistDirectorySoundContext(html, entryOptions)

A hook event that fires when the context menu for a Sound in the PlaylistDirectory is constructed.

Parameters:
Name Type Description
html jQuery

The HTML element to which the context options are attached

entryOptions Array.<ContextMenuEntry>

The context menu entries

(static) getSceneControlButtons(controls)

A hook event that fires when the Scene controls are initialized.

Parameters:
Name Type Description
controls Array.<SceneControl>

The SceneControl configurations

(static) getSceneNavigationContext(html, entryOptions)

A hook event that fires when the context menu for a SceneNavigation entry is constructed.

Parameters:
Name Type Description
html jQuery

The HTML element to which the context options are attached

entryOptions Array.<ContextMenuEntry>

The context menu entries

(static) getSidebarTabEntryContext(html, entryOptions)

A hook event that fires when the context menu for entries in a SidebarTab is constructed. Substitute the SidebarTab name in the hook event to target a specific SidebarTab, for example "getActorDirectoryEntryContext".

Parameters:
Name Type Description
html jQuery

The HTML element to which the context options are attached

entryOptions Array.<ContextMenuEntry>

The context menu entries

(static) getSidebarTabFolderContext(html, entryOptions)

A hook event that fires when the context menu for folders in a SidebarTab is constructed. Substitute the SidebarTab name in the hook event to target a specific SidebarTab, for example "getActorDirectoryFolderContext".

Parameters:
Name Type Description
html jQuery

The HTML element to which the context options are attached

entryOptions Array.<ContextMenuEntry>

The context menu entries

(static) getUserContextOptions(html, entryOptions)

A hook event that fires when the context menu for a PlayersList entry is constructed.

Parameters:
Name Type Description
html jQuery

The HTML element to which the context options are attached

entryOptions Array.<ContextMenuEntry>

The context menu entries

(static) globalVolumeChanged(volume)

A hook event that fires when the user modifies a global volume slider. The hook name needs to be customized to include the type of global volume being changed, one of: globalPlaylistVolumeChanged, globalAmbientVolumeChanged, or globalInterfaceVolumeChanged.

Parameters:
Name Type Description
volume number

The new volume level

(static) hotbarDrop(hotbar, data, slot)

A hook event that fires whenever data is dropped into a Hotbar slot. The hook provides a reference to the Hotbar application, the dropped data, and the target slot. Default handling of the drop event can be prevented by returning false within the hooked function.

Parameters:
Name Type Description
hotbar Hotbar

The Hotbar application instance

data object

The dropped data object

slot number

The target hotbar slot

(static) hoverPlaceableObject(object, hovered)

A hook event that fires when any PlaceableObject is hovered over or out. Substitute the PlaceableObject name in the hook event to target a specific PlaceableObject type, for example "hoverToken".

Parameters:
Name Type Description
object PlaceableObject

The PlaceableObject

hovered boolean

Whether the PlaceableObject is hovered over or not

(static) init()

A hook event that fires as Foundry is initializing, right before any initialization tasks have begun.

(static) initializePointSourceShaders(source, animationType)

A hook event that fires after PointSource shaders have initialized.

Parameters:
Name Type Description
source PointSource

The PointSource

animationType string

The animation type

(static) lightingRefresh(light)

A hook event that fires when the LightingLayer is refreshed.

Parameters:
Name Type Description
light LightingLayer

The LightingLayer

(static) modifyTokenAttribute(data, updates)

A hook event that fires when a token's resource bar attribute has been modified.

Parameters:
Name Type Description
data object

An object describing the modification

Properties
Name Type Description
attribute string

The attribute path

value number

The target attribute value

isDelta boolean

Whether the number represents a relative change (true) or an absolute change (false)

isBar boolean

Whether the new value is part of an attribute bar, or just a direct value

updates objects

The update delta that will be applied to the Token's actor

(static) pastePlaceableObject(copied, createData)

A hook event that fires when any PlaceableObject is pasted onto the Scene. Substitute the PlaceableObject name in the hook event to target a specific PlaceableObject type, for example "pasteToken".

Parameters:
Name Type Description
copied Array.<PlaceableObject>

The PlaceableObjects that were copied

createData Array.<object>

The new objects that will be added to the Scene

(static) pauseGame(paused)

A hook event that fires when the game is paused or un-paused.

Parameters:
Name Type Description
paused boolean

Is the game now paused (true) or un-paused (false)

(static) preCreateDocument(document, data, options, userId) → {boolean|void}

A hook event that fires for every Document type before execution of a creation workflow. Substitute the Document name in the hook event to target a specific Document type, for example "preCreateActor". This hook only fires for the client who is initiating the creation request.

The hook provides the pending document instance which will be used for the Document creation. Hooked functions may modify that data or prevent the workflow entirely by explicitly returning false.

Parameters:
Name Type Description
document Document

The pending document which is requested for creation

data object

The initial data object provided to the document creation request

options object

Additional options which modify the creation request

userId string

The ID of the requesting user, always game.user.id

Returns:

Explicitly return false to prevent creation of this Document

Type
boolean | void

(static) preDeleteDocument(document, options, userId) → {boolean|void}

A hook event that fires for every Document type before execution of a deletion workflow. Substitute the Document name in the hook event to target a specific Document type, for example "preDeleteActor". This hook only fires for the client who is initiating the update request.

The hook provides the Document instance which is requested for deletion. Hooked functions may prevent the workflow entirely by explicitly returning false.

Parameters:
Name Type Description
document Document

The Document instance being deleted

options object

Additional options which modify the deletion request

userId string

The ID of the requesting user, always game.user.id

Returns:

Explicitly return false to prevent deletion of this Document

Type
boolean | void

(static) preUpdateDocument(document, change, options, userId) → {boolean|void}

A hook event that fires for every Document type before execution of an update workflow. Substitute the Document name in the hook event to target a specific Document type, for example "preUpdateActor". This hook only fires for the client who is initiating the update request.

The hook provides the differential data which will be used to update the Document. Hooked functions may modify that data or prevent the workflow entirely by explicitly returning false.

Parameters:
Name Type Description
document Document

The Document instance being updated

change object

Differential data that will be used to update the document

options object

Additional options which modify the update request

userId string

The ID of the requesting user, always game.user.id

Returns:

Explicitly return false to prevent update of this Document

Type
boolean | void

(static) ready()

A hook event that fires when the game is fully ready.

(static) renderApplication(app, html, data)

A hook event that fires whenever this Application is rendered. The hook provides the pending application HTML which will be added to the DOM. Hooked functions may modify that HTML or attach interactive listeners to it.

Parameters:
Name Type Description
app Application

The Application instance being rendered

html jQuery

The inner HTML of the document that will be displayed and may be modified

data object

The object of data used when rendering the application

(static) renderChatMessage(message, html, data)

A hook event that fires for each ChatMessage which is rendered for addition to the ChatLog. This hook allows for final customization of the message HTML before it is added to the log.

Parameters:
Name Type Description
message ChatMessage

The ChatMessage document being rendered

html jQuery

The pending HTML as a jQuery object

data object

The input data provided for template rendering

(static) rtcSettingsChanged(settings, changed)

A hook event that fires when the AV settings are changed.

Parameters:
Name Type Description
settings AVSettings

The AVSettings manager

changed object

The delta of the settings that have been changed

(static) setup()

A hook event that fires when Foundry has finished initializing but before the game state has been set up. Fires before any Documents, UI applications, or the Canvas have been initialized.

(static) sightRefresh(sight)

A hook event that fires when the SightLayer has been refreshed.

Parameters:
Name Type Description
sight SightLayer

The SightLayer

(static) targetToken(user, token, targeted)

A hook event that fires when a token is targeted or un-targeted.

Parameters:
Name Type Description
user User

The User doing the targeting

token Token

The targeted Token

targeted boolean

Whether the Token has been targeted or untargeted

(static) updateCompendium(pack, documents, options, userId)

A hook event that fires whenever the contents of a Compendium pack were modified. This hook fires for all connected clients after the update has been processed.

Parameters:
Name Type Description
pack CompendiumCollection

The Compendium pack being modified

documents Array.<Document>

The locally-cached Documents which were modified in the operation

options object

Additional options which modified the modification request

userId string

The ID of the User who triggered the modification workflow

(static) updateDocument(document, change, options, userId)

A hook event that fires for every Document type after conclusion of an update workflow. Substitute the Document name in the hook event to target a specific Document type, for example "updateActor". This hook fires for all connected clients after the update has been processed.

Parameters:
Name Type Description
document Document

The existing Document which was updated

change object

Differential data that was used used to update the document

options object

Additional options which modified the update request

userId string

The ID of the User who triggered the update workflow

(static) updateWorldTime(worldTime, delta)

A hook event that fires when the World time has been updated.

Parameters:
Name Type Description
worldTime number

The new canonical World time

delta number

The time delta