Class Selection

Selección

La selección del usuario en la presentación activa.

var selection = SlidesApp.getActivePresentation().getSelection();
var currentPage = selection.getCurrentPage();
var selectionType = selection.getSelectionType();
}

Métodos

MétodoTipo de datos que se muestraDescripción breve
getCurrentPage()PageMuestra la Page o la null actualmente activas si no hay una página activa.
getPageElementRange()PageElementRangeMuestra la colección PageElementRange de instancias PageElement que están seleccionadas o null si no hay instancias PageElement seleccionadas.
getPageRange()PageRangeMuestra PageRange una colección de instancias de Page en la tira de imágenes que están seleccionadas o null si la selección no es del tipo SelectionType.PAGE.
getSelectionType()SelectionTypeMuestra el SelectionType.
getTableCellRange()TableCellRangeMuestra la colección TableCellRange de instancias TableCell seleccionadas o null si no hay instancias TableCell seleccionadas.
getTextRange()TextRangeMuestra el TextRange que está seleccionado o null si la selección no es del tipo SelectionType.TEXT.

Documentación detallada

getCurrentPage()

Muestra la Page o la null actualmente activas si no hay una página activa.

var selection = SlidesApp.getActivePresentation().getSelection();
var currentPage = selection.getCurrentPage();
if (currentPage != null) {
  Logger.log('Selected current active page ID: ' + currentPage.getObjectId());
}

Devolvedor

Page

Autorización

Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes alcances:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPageElementRange()

Muestra la colección PageElementRange de instancias PageElement que están seleccionadas o null si no hay instancias PageElement seleccionadas.

var selection = SlidesApp.getActivePresentation().getSelection();
var selectionType = selection.getSelectionType();
if (selectionType == SlidesApp.SelectionType.PAGE_ELEMENT) {
  var currentPage = selection.getCurrentPage();
  var pageElements = selection.getPageElementRange().getPageElements();
  Logger.log('Number of page elements selected: ' + pageElements.length);
}

Devolvedor

PageElementRange

Autorización

Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes alcances:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getPageRange()

Muestra PageRange una colección de instancias de Page en la tira de imágenes que están seleccionadas o null si la selección no es del tipo SelectionType.PAGE.

var selection = SlidesApp.getActivePresentation().getSelection();
var selectionType = selection.getSelectionType();
if (selectionType == SlidesApp.SelectionType.PAGE) {
  var pageRange = selection.getPageRange();
  Logger.log('Number of pages in the flimstrip selected: ' + pageRange.getPages().length);
}
}

Devolvedor

PageRange

Autorización

Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes alcances:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getSelectionType()

Muestra el SelectionType.

var selection = SlidesApp.getActivePresentation().getSelection();
var selectionType = selection.getSelectionType();
if (selectionType == SlidesApp.SelectionType.CURRENT_PAGE) {
  var currentPage = selection.getCurrentPage();
  Logger.log('Selected current active page ID: ' + currentPage.getObjectId());
}

Devolvedor

SelectionType

Autorización

Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes alcances:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getTableCellRange()

Muestra la colección TableCellRange de instancias TableCell seleccionadas o null si no hay instancias TableCell seleccionadas.

var selection = SlidesApp.getActivePresentation().getSelection();
var selectionType = selection.getSelectionType();
if (selectionType == SlidesApp.SelectionType.TABLE_CELL) {
  var currentPage = selection.getCurrentPage();
  var tableCells = selection.getTableCellRange().getTableCells();
  var table = tableCells[0].getParentTable();
  Logger.log('Number of table cells selected: ' + tableCells.length);
}

Devolvedor

TableCellRange

Autorización

Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes alcances:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getTextRange()

Muestra el TextRange que está seleccionado o null si la selección no es del tipo SelectionType.TEXT.

TextRange representa dos situaciones:

1. Se seleccionó el rango de texto. Por ejemplo, si una forma tiene el texto "Hello" y se selecciona "He", el rango que se muestra tendrá TextRange.getStartIndex() = 0 y TextRange.getEndIndex() = 2.

2. Posición del cursor. Por ejemplo, si una forma tiene el texto "Hello" y el cursor está después de "H", ("H|ello"), el rango que se muestra tiene TextRange.getStartIndex() = 1 y TextRange.getEndIndex() = 1.

var selection = SlidesApp.getActivePresentation().getSelection();
var selectionType = selection.getSelectionType();
if (selectionType == SlidesApp.SelectionType.TEXT) {
  var currentPage = selection.getCurrentPage();
  var pageElement = selection.getPageElementRange().getPageElements()[0];
  var textRange = selection.getTextRange();
  Logger.log('Text selected: ' + textRange.asString());
}

Devolvedor

TextRange

Autorización

Las secuencias de comandos que usan este método requieren autorización con uno o más de los siguientes alcances:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations