Skip to content

getDroppedDocument

Jason Godesky edited this page Jul 16, 2026 · 3 revisions

getDroppedDocument is a method that will take the drop event from a DragDrop instance and return the document that was dropped.

Parameters

event: DragEvent

The drop event.

type?: string

A filter that requires that the document match the given type (e.g., 'Actor', 'Item', 'JournalEntry', etc.).

subtype?: string

A filter that requires that the document match the given subtype (the type property on the document).

Returns

A Promise of the document dropped if it (a) can be found and (b) matches the type and subtype provided, or null otherwise.

Examples

import { getDroppedDocument } from '@revolutionarygamesco/common-foundryvtt'

const { ApplicationV2, HandlebarsApplicationMixin } = foundry.applications.api

export class MyApplication extends HandlebarsApplicationMixin(ApplicationV2) {
  character?: foundry.documents.Actor

  // Lots of other stuff to get this set up...

  async _onDrop (event: DragEvent) {
    const character = await getDroppedDocument<foundry.documents.Actor>(event, 'Actor', 'character')
    if (!character) return
    this.character = character
  }
}

Clone this wiki locally