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 en qué botón se ha hecho clic y señalar a la aplicación de Office que ha completado el procesamiento.
Comentarios
Para obtener información sobre la compatibilidad con Excel, Word y PowerPoint, consulte conjuntos de requisitos de comandos de complemento.
A continuación se describe la información de soporte técnico de Outlook.
Consulte Conjuntos de requisitos de comandos de complemento para obtener más información de soporte técnico.
Nivel mínimo de permisos (Outlook):restringido
Modo de Outlook aplicable: Componer o leer
Propiedades
| source | Información sobre el control que desencadenó la llamada a esta función. |
Métodos
| completed(options) | Indica que el complemento ha completado el procesamiento y se cerrará automáticamente. Este método debe llamarse al final de una función invocada por los siguientes:
|
Detalles de las propiedades
source
Información sobre el control que desencadenó la llamada a esta función.
source:Source;
Valor de propiedad
Comentarios
A continuación se describe la información de soporte técnico de Outlook.
Nivel mínimo de permisos: Restringido
Modo de Outlook aplicable: Componer o leer
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.
Este método debe llamarse al final de una función invocada por los siguientes:
Botón de comando de función .
Un complemento de envío en Outlook.
Un complemento de proveedor de reuniones en línea en Outlook.
Un complemento de registro de notas en Outlook para dispositivos móviles.
completed(options?: EventCompletedOptions): void;
Parámetros
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 termina de procesar un evento.
Devoluciones
void
Comentarios
A continuación se describe la información de soporte técnico de Outlook.
Nivel mínimo de permisos: Restringido
Modo de Outlook aplicable: Componer o leer
Importante:
El
optionspará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 el buzón 1.5, el parámetro se admite en losoptionscomplementos móviles del proveedor de reuniones en línea y del registro de notas. Para obtener más información sobre la compatibilidad de API con Outlook para dispositivos móviles, consulte API de JavaScript de Outlook compatibles con Outlook para dispositivos móviles.Los complementos de activación basada en eventos e informes de correo no deseado integrados usan un objeto de evento diferente para indicar cuándo se ha completado el procesamiento de un evento. Para obtener más información, consulte Office.MailboxEvent.
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 });
});
}