Adobe 65009333 Scripting Guide - Page 63

Menus, Understanding the menu model

Page 63 highlights

6 Menus InCopy scripting can add menu items, remove menu items, perform any menu command, and attach scripts to menu items. This chapter shows how to work with InCopy menu scripting. The sample scripts in this chapter are presented in order of complexity, starting with very simple scripts and building toward more complex operations. We assume you read Chapter 2, "Getting Started" and know how to create, install, and run a script. Understanding the menu model The InCopy menu-scripting model is made up of a series of objects that correspond to the menus you see in the application's user interface, including menus associated with panels as well as those displayed on the main menu bar. A menu object contains the following objects: ➤ menuItems - The menu options shown on a menu. This does not include submenus. ➤ menuSeparators - Lines used to separate menu options on a menu. ➤ submenus - Menu options that contain further menu choices. ➤ menuElements - All menuItems, menuSeparators and submenus shown on a menu. ➤ eventListeners - These respond to user (or script) actions related to a menu. ➤ events - The events triggered by a menu. Every menuItem is connected to a menuAction through the associatedMenuAction property. The properties of the menuAction define what happens when the menu item is chosen. In addition to the menuActions defined by the user interface, InCopy scripters can create their own, scriptMenuActions, which associate a script with a menu selection. A menuAction or scriptMenuAction can be connected to zero, one, or more menuItems. The following diagram shows how the different menu objects relate to each other: 63

  • 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

63
6
Menus
InCopy scripting can add menu items, remove menu items, perform any menu command, and attach
scripts to menu items.
This chapter shows how to work with InCopy menu scripting. The sample scripts in this chapter are
presented in order of complexity, starting with very simple scripts and building toward more complex
operations.
We assume you read
Chapter 2, “
Getting Started
and know how to create, install, and run a script.
Understanding the menu model
The InCopy menu-scripting model is made up of a series of objects that correspond to the menus you see
in the application’s user interface, including menus associated with panels as well as those displayed on
the main menu bar. A
menu
object contains the following objects:
menuItems
— The menu options shown on a menu. This does not include submenus.
menuSeparators
— Lines used to separate menu options on a menu.
submenus
— Menu options that contain further menu choices.
menuElements
— All
menuItems
,
menuSeparators
and
submenus
shown on a menu.
eventListeners
— These respond to user (or script) actions related to a menu.
events
— The
events
triggered by a menu.
Every
menuItem
is connected to a
menuAction
through the
associatedMenuAction
property. The
properties of the
menuAction
define what happens when the menu item is chosen. In addition to the
menuActions
defined by the user interface, InCopy scripters can create their own,
scriptMenuActions
,
which associate a script with a menu selection.
A
menuAction
or
scriptMenuAction
can be connected to zero, one, or more
menuItems
.
The following diagram shows how the different menu objects relate to each other: