< Day Day Up > |
Code hints are menus that Dreamweaver opens when you type certain character patterns in the Code view. Code hints offer a typing shortcut by providing 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. Dreamweaver loads Code Hints menus from the CodeHints.xml file in the Configuration/CodeHints folder. You can add Code Hints menus to Dreamweaver by defining them in the CodeHints.xml file. After Dreamweaver loads the contents of CodeHints.xml, you can also add new Code Hints menus dynamically through JavaScript. 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. For information on using JavaScript to add or modify a Code Hints menu, see Code Functions in the Dreamweaver API Reference. Dreamweaver cannot express some types of Code Hints menus through the XML file or the JavaScript API. Both 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, there is no JavaScript hook to open a color picker, so Dreamweaver cannot express the Attribute Values menu using JavaScript. You can only open a menu of text items from which you can insert text. NOTE When you insert text, the insertion pointer is placed after the inserted string. The CodeHints.xml fileThe CodeHints.xml file contains the following entities:
The following example shows the format of the CodeHints.xml file: <codehints> <menugroup name="HTML Entities" enabled="true" > <description> <![CDATA[ When you type a '&', a drop-down menu shows a list of HTML entities. The list of HTML entities is stored in Configuration/CodeHints.xml. ]]> </description> <menu pattern="&"> <menuitem value="&amp;" texticon="&"/> <menuitem value="&lt;" icon="lessThan.gif"/> </menu> </menugroup> <menugroup name="Tag Names" enabled="true" > <description> <![CDATA[ When you type '<', a drop-down menu shows all possible tag names. You can edit the list of tag names using the <a href="javascript:dw.popupTagLibraryEditor()"> Tag Library Editor </a>]]> </description> </menugroup> <menugroup name="Function Arguments" enabled="true" > <description> ... </description> <function pattern="ArraySort(array, sort_type, sort_order)" doctypes="CFML"/> <function pattern="Response.addCookie(Cookie cookie)" doctypes="JSP"/> </menugroup> <codehints> Code Hints tagsThe CodeHints.xml file contains the following tags, which define Code Hints menus. You can use these tags to define additional Code Hints menus. <codehints>Description The codehints tag is the root of the CodeHints.xml file. Attributes None. Contents One or more menugroup tags. Container None. Example <codehints> <menugroup>Description Each menugroup tag corresponds to a type of menu. You can see the menu types that Dreamweaver defines by selecting the Code Hints category from the Preferences dialog box. Select Preferences from the Edit menu to display the Preferences dialog box. You can create a new menu group or add to an existing group. Menu groups are logical collections of menus that the user might want to enable or disable using the Preferences dialog box. Attributes name, enabled, id
Contents The description, menu, and function tags. Container The codehints tag. Example <menugroup name="Session Variables" enabled="true" > <description>Description The description tag contains text that Dreamweaver displays when you select the menu group from the Preferences dialog box. The description text displays below the list of menu groups. The description text might optionally contain a single a tag where the HRef attribute must be a JavaScript URL that Dreamweaver executes if the user clicks the link. Use the XML CDATA construct to enclose any special or illegal characters in the string so that Dreamweaver treats them as text. Attributes None. Contents Description text. Container The menugroup tag. Example <description> <![CDATA[ To add or remove tags and attributes, use the <a href="javascript:dw.tagLibrary .showTagLibraryEditor()">Tag Library Editor</a>. ]]> </description> <menu>Description This tag describes a single pop-up menu. Dreamweaver opens the menu whenever the user types the last character of the string in the pattern attribute. For example, the menu that shows the contents of a Session variable might have a pattern attribute that is equal to "Session.". Attributes pattern, doctypes, casesensitive
Contents The menuitem tag. Container The menugroup tag. Example <menu pattern="CGI." doctypes="ColdFusion"> <menuitem>Description This tag specifies the text for an item in a Code Hints pop-up menu. The menuitem tag also specifies the value to insert into the text when you select the item. Attributes label, value {icon}, {texticon}
Contents None. Container The menu tag. Example <menuitem label="CONTENT_TYPE" value=""CONTENT_TYPE")" icon="shared/mm/images /hintMisc.gif" /> <function>Description This tag replaces the menu tag for specifying function arguments and object methods for a Code Hints pop-up menu. When you type a function or method name in Code view, Dreamweaver opens a menu of function prototypes, displaying the current argument in bold. Each time you type a comma, Dreamweaver updates the menu to display the next argument in bold. For example, if you typed the function name ArrayAppend in a Coldfusion document, the Code Hints menu would display ArrayAppend(array, value). After you type the comma following array, the menu updates to show ArrayAppend(array, value). For object methods, when you type the object name, Dreamweaver opens a menu of the methods that are defined for that object. The set of recognized functions is stored in the Dreamweaver Configuration/CodeHints.xml file. Attributes pattern, doctypes, casesensitive
Contents None. Container The menugroup tag. Example // function example <function pattern="CreateDate(year, month, day)" DOCTYPES="ColdFusion" /> // object method example <function pattern="application.getAttribute(String name)" DOCTYPES="JSP" /> |
< Day Day Up > |