-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPage Switch Custom.sketchplugin
More file actions
39 lines (29 loc) · 1019 Bytes
/
Copy pathPage Switch Custom.sketchplugin
File metadata and controls
39 lines (29 loc) · 1019 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Switch between pages (cmd ')
var current_page = [doc currentPage]
var pages = [doc pages]
var number_pages = [pages count]
var current_page_index = [pages indexOfObject:current_page]
function createSelect(msg, items, selectedItemIndex){
selectedItemIndex = selectedItemIndex || 0
var accessory = [[NSComboBox alloc] initWithFrame:NSMakeRect(0,0,200,25)]
[accessory addItemsWithObjectValues:items]
[accessory selectItemAtIndex:selectedItemIndex]
var alert = [[NSAlert alloc] init]
[alert setMessageText:msg]
[alert addButtonWithTitle:'OK']
[alert addButtonWithTitle:'Cancel']
[alert setAccessoryView:accessory]
var responseCode = [alert runModal]
var sel = [accessory indexOfSelectedItem]
return [responseCode, sel]
}
var options = []
for (var i = 0; i < number_pages; i++) {
var p = pages[i]
options[i] = [p name]
}
var choice = createSelect('Choose the page',options, 1)
if (choice[0] == 1000) {
var switch_to_index = choice[1]
[doc setCurrentPage:pages[switch_to_index]]
}