beautypg.com

Chapter 18: code, Code functions, Dreamweaver.codehints.addmenu() – Adobe Dreamweaver API Reference CS5 User Manual

Page 445

background image

440

Last updated 8/27/2013

Chapter 18: Code

The code functions let you perform operations on a document that appears in Code view. The operations include
adding new menu or function tags to a code hints menu, finding and replacing string patterns, deleting the current
selection from a document, printing all or selected code, editing tags, or applying syntax formatting to selected code.

Code functions

Code Hints are menus that Adobe® Dreamweaver® CS5 opens when you type certain character patterns in Code view.
Code Hints provide a typing shortcut by offering a list of strings that potentially complete the string you are typing. If
the string you are typing appears in the menu, you can scroll to it and press Enter or Return to complete your entry.
For example, when you type <, a pop-up menu shows a list of tag names. Instead of typing the rest of the tag name, you
can select the tag from the menu to include it in your text.

You can add Code Hints menus to Dreamweaver by defining them in the CodeHints.xml file. For information on the
CodeHints.xml file, see Extending Dreamweaver.

You can also add new Code Hints menus dynamically through JavaScript after Dreamweaver loads the contents of the
CodeHints.xml file. For example, JavaScript code populates the list of session variables in the Bindings panel. You can
use the same code to add a Code Hints menu. So, when a user types Session in Code view, Dreamweaver displays a
menu of session variables.

The CodeHints.xml file and the JavaScript API expose a useful subset of the Code Hints engine, but some
Dreamweaver functionality is not accessible. For example, Dreamweaver does not have a JavaScript hook to open a
color picker, so it cannot express the Attribute Values menu using JavaScript. You can only open a menu of text items
from which you can insert text.

Code Coloring lets you specify code color styles and to modify existing code coloring schemes or create new ones. You
can specify code coloring styles and schemes by modifying the Colors.xml and code coloring scheme files. For more
information on these files, see Extending Dreamweaver.

The JavaScript API for Code Hints and Code Coloring consists of the following functions.

dreamweaver.codeHints.addMenu()

Availability
Dreamweaver MX.

Description
Dynamically defines a new

menu

tag in the CodeHints.xml file. If a menu tag with the same pattern and document type

exists, this function adds items to the existing menu.

Arguments

menuGroupId

,

pattern

,

labelArray

,

{valueArray}

,

{iconArray}

,

{doctypes}

,

{casesensitive

},

{object}

,

{descriptionArray}

,

{dismissChars}

,

{allowWhitespacePrefix}

,

{restriction}

,

{type}

,

{bForcedOnly}

,

{allowMultipleTimes}

,

{docURI}, {alias}

The

menuGroupId

argument is the ID attribute for one of the

menugroup

tags.