< Day Day Up > |
In addition to the standard HTML form elements, Dreamweaver supports custom controls to help you create flexible, professional-looking interfaces, as described in the following list:
Editable select listsExtension UIs often contain pop-up lists that are defined using the select tag. In Dreamweaver, you can make pop-up lists in extensions editable by adding editable="true" to the select tag. To set a default value, set the editText attribute and the value that you want the select list to display. The following example shows the settings for an editable select list: <select name="travelOptions" style="width:250px" editable="true" editText="other (please specify)"> <option value="plane">plane</option> <option value="car">car</option> <option value="bus">bus</option> </select> When you use select lists in your extensions, check for the presence and value of the editable attribute. If no value is present, the select list returns the default value of false, which indicates that the select list is not editable. As with standard, noneditable select lists, editable select lists have a selectedIndex property (see "Objects, properties, and methods of the Dreamweaver DOM" on page 129). This property returns-1 if the text box is selected. To read the value of an active editable text box into an extension, read the value of the editText property. The editText property returns the string that the user entered into the editable text box, the value of the editText attribute, or an empty string if no text has been entered and no value has been specified for editText. Dreamweaver adds the following custom attributes for the select tag to control editable pop-up lists:
NOTE Editable select lists are available in Dreamweaver. The following example creates a Command extension that contains an editable select list using common JavaScript functions: To create the example:
To test the example:
Database controlsUsing Dreamweaver, you can extend the HTML select tag to create a database tree control. You can also add a variable grid control. The database tree control displays database schema, and the variable grid control displays tabular information. The following figure shows an advanced Recordset dialog box that uses a database tree control and a variable grid control: Adding a database tree controlThe database tree control has the following attributes:
Any option tags that are placed inside the select tag are ignored. To add a database tree control to a dialog box, you can use the following sample code with appropriate substitutions for quoted variables: <select name="DBTree" style="width:400px;height:110px" type="mmdatabasetree" connection="connectionName" noexpandbuttons showHeaders></select> You can change the connection attribute to retrieve selected data and display it in the tree. You can use the DBTreeControl attribute as a JavaScript wrapper object for the new tag. For more examples, see the DBTreeControlClass.js file in the Configuration/Shared/Common/Scripts folder. Adding a variable grid controlThe variable grid control has the following attributes:
The following example adds a simple variable grid control to a dialog box: <select name="ParamList" style="width:515px;" type="mmparameterlist columns"="Name,SQL Data Type,Direction,Default Value,Run-time Value" size=6></select> The following example creates a variable grid control that is 500 pixels wide, with five columns of various widths: <select name="ParamList" style="width:800px;" type="mmparameterlist" columns="Name,SQL Data Type,Direction, Default Value,Run-time Value" columnWidth="100,25,11," size=6> This example creates two blank columns that are 182 pixels wide. (The specified columns total 136. The total width of the variable grid control is 500. The remaining space after the first three columns are placed is 364. Two columns remain; 364 divided by 2 is 182.) This variable grid control also has a JavaScript wrapper object that should be used to access and manipulate the variable grid control's data. You can find the implementation in the GridControlClass.js file in the Configuration/Shared/MM/Scripts/Class folder. Adding tree controlsTree controls display data in a hierarchical format and let users expand and collapse nodes in the tree. The MM:trEECONTROL tag lets you create tree controls for any type of information; unlike the database tree control that is described in "Adding a database tree control" on page 117, no association with a database is required. The Dreamweaver Keyboard Shortcuts editor uses the tree control, as shown in the following figure: Creating a tree controlThe MM:trEECONTROL tag creates a tree control and can use one or more tags to add structure, as described in the following list:
MM:TREECONTROL tags have the following attributes:
MM:trEECOLUMN tags have the following attributes:
For readability, trEECOLUMN tags should follow immediately after the MM:treeControl tag, as shown in the following example: <MM:TREECONTROL name="tree1"> <MM:TREECOLUMN name="Column1" width="100" state="visible"> <MM:TREECOLUMN name="Column2" width="80" state="visible"> ... </MM:TREECONTROL> The MM:TREENODE attributes are described in the following table:
For example, the following tree control has all its nodes expanded: <mm:treecontrol name="test" style="height:300px;width:300px"> <mm:treenode value="rootnode1" state="expanded"> <mm:treenode value="node1" state="expanded"></mm:treenode> <mm:treenode value="node3" state="expanded"></mm:treenode> </mm:treenode> <mm:treenode value="rootnode2" state="expanded"> <mm:treenode value="node2" state="expanded"></mm:treenode> <mm:treenode value="node4" state="expanded"></mm:treenode> </mm:treenode> </mm:treecontrol> Manipulating content within a tree controlTree controls and the nodes within them are implemented as HTML tags. They are parsed by Dreamweaver and stored in the document tree. These tags can be manipulated in the same way as any other document node. For more information on DOM functions and methods, see Chapter 5, "The Dreamweaver Document Object Model," on page 127. Adding nodesTo add a node to an existing tree control programmatically, set the innerHTML property of the MM:trEECONTROL tag or one of the existing MM:trEENODE tags. Setting the inner HTML property of a tree node creates a nested node. The following example adds a node to the top level of a tree: var tree = document.myTreeControl; //add a top-level node to the bottom of the tree tree.innerHTML = tree.innerHTML + '<mm:treenode name="node3" value="node3">'; Adding a child nodeTo add a child node to the currently selected node set the innerHTML property of the selected node. The following example adds a child node to the currently selected node: var tree = document.myTreeControl; var selNode = tree.selectedNodes[0]; //deselect the node, so we can select the new one selnode.removeAttribute("selected"); //add the new node to the top of the selected node's children selNode.innerHTML = '<mm:treenode name="item10" value="New item11" expanded selected>' + selNode.innerHTML; Deleting nodesTo delete the currently selected node from the document structure, use the innerHTML or outerHTML properties. The following example deletes the entire selected node and any children: var tree = document.myTreeControl; var selNode = tree.selectedNodes[0]; selNode.outerHTML = ""; A color button control for extensionsIn addition to the standard input types such as text, checkbox, and button, Dreamweaver supports mmcolorbutton, an additional input type in extensions. Specifying <input type="mmcolorbutton"> in your code causes a color picker to appear in the UI. You can set the default color for the color picker by setting a value attribute on the input tag. If you do not set a value, the color picker appears grey by default and the value property of the input object returns an empty string. The following example shows a valid mmcolorbutton tag: <input type="mmcolorbutton" name="colorbutton" value="#FF0000"> <input type="mmcolorbutton" name="colorbutton" value="teal"> A color button has one event, onChange, which is triggered when the color changes. You might want to keep a text box and a color picker synchronized. The following example creates a text box that synchronizes the color of the text box with the color of the color picker: <input type = "mmcolorbutton" name="fgcolorPicker" onChange="document.fgcolorText .value=this.value"> <input type = "test" name="fgcolorText" onBlur="document.fgColorPicker.value=this.value"> In this example, when the user changes the value of the text box and then tabs or clicks elsewhere, the color picker updates to show the color that is specified in the text box. Whenever the user selects a new color with the color picker, the text box updates to show the hex value for that color. |
< Day Day Up > |