-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathMenuAccess.jsx
More file actions
92 lines (78 loc) · 1.99 KB
/
MenuAccess.jsx
File metadata and controls
92 lines (78 loc) · 1.99 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#target 'indesign'
// Path to IdExtenso entry point.
// ---
#include '../$$.jsxinc'
// Dom.Menu module.
// ---
#include '../etc/$$.Dom.Menu.jsxlib'
// Load the framework
// ---
$$.load();
// =============================================================================
// MenuAccess [210328]
// Accessing existing menu components (menus, submenus, or menuitems.)
// ---
// Demonstrates:
// - Using `Dom.Menu.get()` routine.
// =============================================================================
try
{
const LINE = "\r---------\r";
var k,m,msg;
// Testing various paths. All key strings provided below
// SHOULD remain locale-independent ('$ID/...') unless
// the InDesign locale is fixed (then your script won't
// work in other UI languages.)
// ---
const PATHS =
{
ContextualTextMnu: [ '$ID/RtMouseText' ],
FindChangeCmd: [ 0, '', '$ID/EditMenu_FindChange' ],
ChangeCaseMnu: [ '$ID/Main', '', '$ID/CCase Cmd' ],
LastCaseCmd: [ 0,'','$ID/CCase Cmd', -1],
FileMnu: [ 0, '$ID/&File' ],
OpenDocCmd: [ '$ID/Main', 0, '$ID/Open...' ],
CrazyTest: [ 0, '$ID/abcd', 123 ],
ContentAwareCC: [ '', '', '$ID/kContentAwareFit' ],
}
for( k in PATHS )
{
if( !PATHS.hasOwnProperty(k) ) continue;
m = $$.Dom.Menu.get(PATHS[k]);
if( m )
{
msg = __("%1.%2This %3 is available.%2Spec: %4\r.name: %5\r.title: %6"
, k
, LINE
, m.constructor.name
, m.toSpecifier()
, m.name
, m.title
);
}
else
{
msg = __("%1.%2This component is NOT available:\r[%3]"
, k
, LINE
, PATHS[k].join('] [')
);
}
alert( msg );
if( 'FindChangeCmd' == k && (m||0).enabled )
{
m = m.associatedMenuAction;
m.enabled && $$.yesNo("Run the Find/Change command?") && m.invoke();
}
}
}
catch(e)
{
// In case something goes wrong.
// ---
$$.receiveError(e);
}
// =============================================================================
// Please, unload the framework to cleanup memory.
// ---
$$.unload();