hookEvents

hookEvents

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

Methods

(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) 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) 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) 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) 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) 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) 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) 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