Release Notes > 12.0.1.0 > Updates in This Release > Arbortext Layout Developer Template Events > Template Events in Layout Developer
  
Template Events in Layout Developer
The new templates events can be set through the fTemplate.events object. This object can set several events (see fTemplateEvents):
editBarChanged — the function associated with this event is called when the text stream in the edit bar changes to another stream. This might be when editing another tag, or when switching mode. The function is passed the name of the new stream being opened. If no stream is opened (eg changing from Text to Page mode), no argument is passed.
modeChanged — the function associated with this event is called when the user changes working mode. For example, switching from Text to Document mode. The new mode number is passed to the function as an argument. Document Mode = 0, Page Mode = 1, Text Mode = 2, Graphics Mode = 3, Blacklining Mode = 4, View Mode = 5.
pageChanged — the function associated with this event is called when the user changes the current page. It is not called when Layout Developer changes pages as part of formatting. The function is passed the page position and the new fPage object as arguments.
selectedFrameChanged — the function associated with this event is called when the user selects a new frame. The array of selected frames is passed to the function as an argument (it is possible to select more than one frame).
selectedLayerChanged — the function associated with this event is called when the user changes the selected layer. The new fLayer object is passed to the function as an argument.
templateClose — the function associated with this event is called when the template is closed. The path of the template’s location is passed to the function as an argument.
templateOpen — the function associated with this event is called when the template is opened. As with templateClose, the location path of the template is passed to the function as an argument
templateSave — the function associated with this event is called when the template is saved. Again, the new path of the template is passed to the function as an argument.
To set the events up, use something like this:
template.events.editBarChanged = "editChangeFunction";
Where ‘editChangeFunction’ is the name of the JavaScript tag to call. In that tag, one could use something like this:
var streamName;
if (arguments[0]) {
streamName = arguments[0].name;
application.alert("Opened " + streamName);
}
It is a good idea to test if there are arguments before trying to use them as it is possible to call this function with no arguments.
One of the reasons for introducing Template Events to Layout Developer is to work with the customisable left bar. The events can and should be used to trigger left bar updates or to build new lists to display in the left bar. For example, a customised left bar could show all the layers and frames on the current page. The pageChanged event could be used to rebuild the left bar for the new page. The selectedLayerChanged event could be used to highlight the selected layer’s name in the left bar and the selectedFrameChanged event could be used to highlight the frame names in the left bar too.