Compartir a través de


Office.AddinCommands.Event interface

El Event objeto se pasa como parámetro a las funciones de complemento invocadas por los botones de comando de función. El objeto permite al complemento identificar qué botón se ha hecho clic y indicar a la aplicación de Office que ha completado su procesamiento.

Comentarios

Para obtener información sobre la compatibilidad en Excel, Word y PowerPoint, vea Conjuntos de requisitos de comandos de complementos.

En los esquemas siguientes se describe la información de soporte técnico para Outlook.

[ Conjunto de API: Buzón 1.3 ]

Nivel mínimo de permiso (Outlook):restringido

Modo de Outlook aplicable: Compose o lectura

Propiedades

source

Información sobre el control que desencadenó llamar a esta función.

Métodos

completed(options)

Indica que el complemento ha completado el procesamiento y se cerrará automáticamente.

Se debe llamar a este método al final de una función invocada por lo siguiente:

Detalles de las propiedades

source

Información sobre el control que desencadenó llamar a esta función.

source:Source;

Valor de propiedad

Comentarios

En los esquemas siguientes se describe la información de soporte técnico para Outlook.

[ Conjunto de API: Buzón 1.3 ]

Nivel mínimo de permiso: restringido

Modo de Outlook aplicable: Compose o lectura

Ejemplos

// In this example, consider a button defined in an add-in manifest.
// The following is the XML manifest definition. Below it is the Teams 
// manifest (preview) definition.
//
//<Control xsi:type="Button" id="eventTestButton">
//    <Label resid="eventButtonLabel" />
//    <Tooltip resid="eventButtonTooltip" />
//    <Supertip>
//        <Title resid="eventSuperTipTitle" />
//        <Description resid="eventSuperTipDescription" />
//    </Supertip>
//    <Icon>
//        <bt:Image size="16" resid="blue-icon-16" />
//        <bt:Image size="32" resid="blue-icon-32" />
//        <bt:Image size="80" resid="blue-icon-80" />
//    </Icon>
//    <Action xsi:type="ExecuteFunction">
//        <FunctionName>testEventObject</FunctionName>
//    </Action>
//</Control>
//
// The Teams manifest (preview) definition is the following.
// Ellipses("...") indicate omitted properties.
//
//     "extensions": [
//         {
//             ...
//             "runtimes": [
//                 {
//                  "id": "CommandsRuntime",
//                  "type": "general",
//                  "code": {
//                      "page": "https://localhost:3000/commands.html",
//                      "script": "https://localhost:3000/commands.js"
//                  },
//                  "lifetime": "short",
//                  "actions": [
//                      {
//                          "id": "testEventObject",
//                          "type": "executeFunction",
//                          "displayName": "testEventObject"
//                      }
//                  ]
//              }
//             ],
//             "ribbons": [
//                 {
//                     ...
//                     "tabs": [
//                         ...
//                         "groups": [
//                             ...
//                             "controls": [
//                                 {
//                                      "id": "eventTestButton",
//                                      "type": "button",
//                                      "label": "Perform an action",
//                                      "icons": [
//                                          {
//                                              "size": 16,
//                                              "file": "https://localhost:3000/assets/blue-icon-16.png"
//                                          },
//                                          {
//                                              "size": 32,
//                                              "file": "https://localhost:3000/assets/blue-icon-32.png"
//                                          },
//                                          {
//                                              "size": 80,
//                                              "file": "https://localhost:3000/assets/blue-icon-80.png"
//                                          }
//                                      ],
//                                      "supertip": {
//                                          "title": "Perform an action",
//                                          "description": "Perform an action when clicked."
//                                      },
//                                      "actionId": "testEventObject"
//                                  }
//                             ]
//                         ]
//                     ]                           
//                 }
//             ]
//         }
//     ]



// The button has an id set to "eventTestButton", and will invoke
// the testEventObject function defined in the add-in.
// That function looks like this:
function testEventObject(event) {
    // The event object implements the Event interface.

    // This value will be "eventTestButton".
    const buttonId = event.source.id;

    // Signal to the host app that processing is complete.
    event.completed();
}
// Function is used by two buttons:
// button1 and button2
function multiButton (event) {
    // Check which button was clicked.
    const buttonId = event.source.id;

    if (buttonId === 'button1') {
        doButton1Action();
    } else {
        doButton2Action();
    }

    event.completed();
}

Detalles del método

completed(options)

Indica que el complemento ha completado el procesamiento y se cerrará automáticamente.

Se debe llamar a este método al final de una función invocada por lo siguiente:

completed(options?: EventCompletedOptions): void;

Parámetros

options
Office.AddinCommands.EventCompletedOptions

Opcional. En Outlook, un objeto que especifica el comportamiento de un complemento de envío, un complemento de proveedor de reuniones en línea o un complemento móvil de registro de notas cuando finaliza el procesamiento de un evento.

Devoluciones

void

Comentarios

En los esquemas siguientes se describe la información de soporte técnico para Outlook.

[ Conjunto de API: Buzón 1.3 ]

Nivel mínimo de permiso: restringido

Modo de Outlook aplicable: Compose o lectura

Importante: El options parámetro solo se aplica a los complementos de Outlook. Se introdujo en el buzón 1.8. Aunque Outlook en Android y en iOS admiten hasta mailbox 1.5, el options parámetro es compatible con el proveedor de reuniones en línea y los complementos móviles de registro de notas. Para obtener más información sobre la compatibilidad con API en Outlook en dispositivos móviles, vea API de JavaScript de Outlook compatibles con Outlook en dispositivos móviles.

Ejemplos

// For the following example, the processItem function is
// defined in the FunctionFile referenced from the add-in manifest,
// and maps to the FunctionName of the action in the associated button control.
function processItem(event) {
    // Do some processing.

    event.completed();
}
// In this example, the checkMessage function was registered as an event handler for ItemSend.
function checkMessage(event) {
    // Get the item being sent.
    const outgoingMsg = Office.context.mailbox.item;

    // Check if subject contains "BLOCK".
    outgoingMsg.subject.getAsync(function (result) {
        // Subject is in `result.value`.
        // If search term "BLOCK" is found, don't send the message.
        const notFound = -1;
        const allowEvent = (result.value.indexOf('BLOCK') === notFound);
        event.completed({ allowEvent: allowEvent });
    });
}