Code hints

 < 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 file

The CodeHints.xml file contains the following entities:

  • A list of all the menu groups

    Dreamweaver displays the list of menu groups when you select the Code Hints category from the Preferences dialog box. You can open the Preferences dialog box by selecting Edit > Preferences. Dreamweaver MX provides the following menu groups or types of Code Hints menus: Tag Names, Attribute Names, Attribute Values, Function Arguments, Object Methods and Variables, and HTML Entities.

  • The description for each menu group

    The description appears in the Preferences dialog box for the Code Hints category when you select the menu group in the list. The description for the selected entry appears below the menu group list.

  • Code Hints menus

    A menu consists of a pattern that triggers the Code Hints menu and a list of menu items. For example, a pattern such as "&" could trigger a menu such as "&amp;", "&gt;", "&lt;".

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="&amp;">       <menuitem value="&amp;amp;" texticon="&amp;"/>       <menuitem value="&amp;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 tags

The 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 

  • The name attribute is the localized name that appears in the list of menu groups in the Code Hints category of the Preferences dialog box.

  • The enabled attribute indicates whether the menu group is currently checked or enabled. A menu group that is enabled appears with a check mark next to it in the Code Hints category of the Preferences dialog box. Assign a true value to enable the menu group or a false value to disable a menu group.

  • The id attribute is a nonlocalized identifier that refers to the menu group.

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 

  • The pattern attribute specifies the pattern of typed characters that cause Dreamweaver to open the Code Hints menu. If the first character of the pattern is a letter, number, or underscore, Dreamweaver displays the menu only if the character that precedes the pattern in the document is not a letter, number, or underscore. For example, if the pattern is "Session.", Dreamweaver does not display the menu if the user types "my_Session.".

  • The doctypes attribute specifies that the menu is active only for the specified document types. This attribute lets you specify different lists of function names for ASP-JavaScript (ASP-JS), Java Server Pages (JSP), Macromedia ColdFusion, and so on. You can specify the doctypes attribute as a comma-separated list of document type IDs. See the Dreamweaver Configuration/Documenttypes/MMDocumentTypes.xml file for a list of Dreamweaver document types.

  • The casesensitive attribute specifies whether the pattern is case-sensitive. The possible values for the casesensitive attribute are true, false, or a subset of the comma-separated list that you specify for the doctypes attribute. The list of document types lets you specify that the pattern is case-sensitive for some document types but not for others. The value defaults to false if you omit this attribute. If the casesensitive attribute is a value of true, the Code Hints menu will open only if the text that the user types exactly matches the pattern that the pattern attribute specifies. If the casesensitive attribute is a value of false, the menu appears even if the pattern is lowercase and the text is uppercase.

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} 

  • The label attribute is the string that Dreamweaver displays in the pop-up menu.

  • The value attribute is the string that Dreamweaver inserts in the document when you select the menu item. When the user selects the item from the menu and presses Enter or Return, Dreamweaver replaces all the text that the user typed since the menu opened. The user typed the pattern-matching characters before the menu opened, so Dreamweaver does not insert them again. For example, if you want to insert &amp, which is the HTML entity for ampersand (&), you can define the following menu and menuitem tags:

     <menu pattern="&amp;"> <menuitem label="&amp;amp;" value="amp;" texticon="&amp;"/> 

    The value attribute does not include the ampersand (&) character because the user typed it before the menu opened.

  • The icon attribute, which is optional, specifies the path to an image file that Dreamweaver displays as an icon to the left of the menu text. The location is expressed as a URL, relative to the Configuration folder.

  • The texticon attribute, which is optional, specifies a text string to appear in the icon area instead of an image file. This attribute is used for the HTML Entities menu.

Contents

None.

Container

The menu tag.

Example

<menuitem label="CONTENT_TYPE" value="&quot;CONTENT_TYPE&quot;)" 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 

  • The pattern attribute specifies the name of the function and its argument list. For methods, the pattern attribute describes the name of the object, the name of the method, and the method's arguments. For a function name, the Code Hints menu appears when the user types functionname(. The menu shows the list of arguments for the function. For an object method, the Code Hints menu appears when the user types objectname. (including the period). This menu shows the methods that have been specified for the object. After that, the Code Hints menu opens a list of the arguments for the method in the same way it does for a function.

  • The doctypes attribute specifies that the menu is active only for the specified document types. This attribute lets you specify different lists of function names for ASP-JavaScript (ASP-JS), Java Server Pages (JSP), Macromedia ColdFusion, and so on. You can specify the doctypes attribute as a comma-separated list of document type IDs. For a list of Dreamweaver document types, see the Dreamweaver Configuration/Documenttypes/MMDocumentTypes.xml file.

  • The casesensitive attribute specifies whether the pattern is case-sensitive. The possible values for the casesensitive attribute are true, false, or a subset of the comma-separated list that you specify for the doctypes attribute. The list of document types lets you specify that the pattern is case-sensitive for some document types but not for others. The value defaults to false if you omit this attribute. If the casesensitive attribute is a value of true, the Code Hints menu appears only if the text that the user types exactly matches the pattern that the pattern attribute specifies. If the casesensitive attribute is a value of false, the menu appears even if the pattern is lowercase and the text is uppercase.

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 > 


    Developing Extensions for Macromedia Dreamweaver 8
    Developing Extensions for Macromedia Dreamweaver 8
    ISBN: 0321395409
    EAN: 2147483647
    Year: 2005
    Pages: 282

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net