SDK Programmer's Guide
Event
cmSiteSubOpen
cmSiteSubPublish
cmSiteSubSettings
Registering context menu handlers
The target for all context-menu events is the
register it with the app object. For example, to register a handler that adds a submenu to the Layout
view's context menu:
<script>
// define handler
function myLayoutCMSub(cmEvt) {
//body of function adds submenu, responds to selection
}
// register handler with app
function initializeModule() {
app.addEventListener( 'cmLayout', myLayoutCMSub);
}
</script>
Defining context menu handlers
Handlers are passed the
action that generated the event. Actions are:
: A submenu was closed.
close
extend
: A submenu was opened.
open
: The context menu is about to open; the script can set the enabled state of items.
setup
signal
Your handler must check the action, and provide a response:
To add submenus and menu items, check for the extend action, which occurs when the menu is first
●
created.
To respond to a menu item selection, check for the signal action. This is like the
●
menu-bar menus.
To enable or disable menu items, check for the setup action. This is like the
●
menu-bar menus.
➤
Context menu example
This example adds a new item and a submenu with two items to the Layout view context menu, in
response to the extend action. When one of the new items is selected, this handler prints out a notification
in response to the signal action:
function startModule()
{
app.addEventListener ( 'cmLayout',
contextMenuEvent
: The context menu has been set up; the script can add submenus or menu items to it.
: A menu item was clicked.
Adobe GoLive CS2 SDK
Generated for:
The Open submenu of the context menu for files listed in the Site
window.
The Publish Server submenu of the context menu for the Site
window.
The Settings submenu of the context menu for the Site window.
app
Object. That is, to register a handler for any of the events,
object; this object's action property contains the specific
Menus and Toolbars
menuSignal
event for
menuSetup
event for
51