انتخاب کاربر در ارائه فعال.
var selection = SlidesApp.getActivePresentation().getSelection(); var currentPage = selection.getCurrentPage(); var selectionType = selection.getSelectionType(); }
مواد و روش ها
روش | نوع برگشت | توضیح مختصر |
---|---|---|
getCurrentPage() | Page | Page فعال فعلی را برمیگرداند یا اگر صفحه فعالی وجود نداشته باشد، null برمیگرداند. |
getPageElementRange() | PageElementRange | مجموعه PageElementRange از نمونه های PageElement را برمی گرداند که در صورت انتخاب هیچ نمونه PageElement انتخاب یا null می شوند. |
getPageRange() | PageRange | PageRange مجموعه ای از نمونه های Page را در نوار نواری برمی گرداند که در صورتی که انتخاب از نوع SelectionType.PAGE نباشد، انتخاب شده یا null است. |
getSelectionType() | SelectionType | SelectionType را برمی گرداند. |
getTableCellRange() | TableCellRange | مجموعه TableCellRange از نمونههای TableCell را برمیگرداند که در صورت انتخاب هیچ نمونه TableCell انتخاب شده یا null هستند. |
getTextRange() | TextRange | اگر انتخاب از نوع SelectionType.TEXT نباشد، TextRange انتخاب شده یا null برمیگرداند. |
مستندات دقیق
getCurrentPage()
Page
فعال فعلی را برمیگرداند یا اگر صفحه فعالی وجود نداشته باشد، null
برمیگرداند.
var selection = SlidesApp.getActivePresentation().getSelection(); var currentPage = selection.getCurrentPage(); if (currentPage != null) { Logger.log('Selected current active page ID: ' + currentPage.getObjectId()); }
برگشت
مجوز
اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getPageElementRange()
مجموعه PageElementRange
از نمونه های PageElement
را برمی گرداند که در صورت انتخاب هیچ نمونه PageElement
انتخاب یا null
می شوند.
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); }
برگشت
مجوز
اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getPageRange()
PageRange
مجموعه ای از نمونه های Page
را در نوار نواری برمی گرداند که در صورتی که انتخاب از نوع SelectionType.PAGE
نباشد، انتخاب شده یا null
است.
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); } }
برگشت
مجوز
اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getSelectionType()
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()); }
برگشت
مجوز
اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getTableCellRange()
مجموعه TableCellRange
از نمونههای TableCell
را برمیگرداند که در صورت انتخاب هیچ نمونه TableCell
انتخاب شده یا null
هستند.
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); }
برگشت
مجوز
اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getTextRange()
اگر انتخاب از نوع SelectionType.TEXT
نباشد، TextRange
انتخاب شده یا null
برمیگرداند.
TextRange
دو سناریو را نشان می دهد:
1. محدوده متن انتخاب شده است. به عنوان مثال اگر شکلی دارای متن "Hello" باشد و "He" انتخاب شده باشد، محدوده بازگشتی دارای TextRange.getStartIndex()
= 0 و TextRange.getEndIndex()
= 2 است.
2. موقعیت مکان نما. به عنوان مثال، اگر شکلی دارای متن "Hello" باشد، و مکان نما بعد از "H"، ("H|ello")، محدوده بازگشتی دارای TextRange.getStartIndex()
= 1 و 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()); }
برگشت
مجوز
اسکریپت هایی که از این روش استفاده می کنند نیاز به مجوز با یک یا چند مورد از حوزه های زیر دارند:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations