DekGenius.com
Previous Section Next Section

19.2 Customizing Keyboard Shortcuts

You can modify Dreamweaver keyboard shortcuts by editing the menus.xml file, but it is easier to assign shortcuts via the Keyboard Shortcuts dialog box. Keyboard shortcuts are summarized in Appendix A. Some shortcuts may not work on some computers, particularly laptops, which intercept some function keys. If a shortcut does not work on the Macintosh, turn off the Hot Function Key option in the Keyboard Control Panel.

19.2.1 The Keyboard Shortcuts Dialog Box

Use the Edit figs/U2192.gif Keyboard Shortcuts command to open the Keyboard Shortcuts dialog box shown in Figure 19-1.

Figure 19-1. The Keyboard Shortcuts dialog box
figs/dwn_1901.gif

This dialog box includes options to customize and manage keyboard shortcut sets (i.e., a collection of keyboard shortcuts):

Current Set

Choose from one of the factory sets—BBEdit, Dreamweaver 3, or HomeSite—that emulate the keyboard shortcuts of other programs, or select Macromedia Standard (the default DW4 shortcuts). Custom sets that you define also appear in this pop-up list.

Commands

After selecting a custom set from the Current Set pop-up list, select which menu bar to modify from the Commands pop-up list. The available options differ slightly between Windows and the Macintosh.

Menu Commands

Dreamweaver's main menu bar commands (positioned at the top of the Macintosh monitor or appearing in the Document window under Windows).

Site Menu Commands (Windows only)

Site window menu bar commands. There is no separate Site window menu bar on the Macintosh. See Chapter 6 for details.

Code Editing

Commands that work in the Document window's Code view (also apply to the Code Inspector).

Document Editing

Commands that work in the Document window's Design view.

Site Window (Windows only)

Additional shortcut keys that work when the Site window is active but don't rely on the Site window menu bar. These shortcuts are included in the Document Editing category on the Macintosh.

Menu list

Use the plus (+) icons (Windows) or triangles (Macintosh) next to the menu names, to expand a menu and display the items within it. Select the menu item that you want to modify.

Shortcuts

This field lists the current shortcut for the selected menu item. Click the plus (+) button to add multiple keyboard shortcuts for the same menu command. Use the minus (-) button to remove keyboard shortcuts.

Press Key

Once you've selected the menu item to modify, click in the Press Key field to make it active. Press one or more keys to be used for the keyboard shortcut, such as the function keys or Ctrl+Shift+Q. Dreamweaver fills in the mnemonic codes in the Press Key field for you (don't attempt to type C-t-r-l to specify the Ctrl key, just press the Ctrl key). Click the Change button to replace the currently selected line in the Shortcuts field with the new shortcut specified in the Press Key field (if the Press Key field is blank, Dreamweaver erases the current keyboard shortcut).

Define a keyboard shortcut for each menu option as desired. Click the OK button to save your changes or the Cancel button to abort them.

You cannot modify the keyboard shortcuts in a built-in (factory) set. Duplicate a set using the Duplicate Set icon, and then make changes to the duplicate set.

19.2.2 Managing Custom Keyboard Shortcuts

When you enter a keyboard shortcut in the Press Key field of the Keyboard Shortcuts dialog box, Dreamweaver tells you whether the shortcut is already in use. Although the Press Key field is a convenient way to check if a keyboard shortcut is available, it isn't completely reliable. It reports keyboard shortcuts used on either Windows or Macintosh, even if they aren't active on the current platform.

To use a keyboard shortcut already assigned to a <menuitem> tag, remove the key="shortcut" attribute from that tag in the menus.xml file. The same keyboard shortcut can be used for different purposes on different platforms (Macintosh or Windows) using the <menuitem> tag's platform attribute. The same keyboard shortcut can be used for different applications (Dreamweaver or UltraDev) using the <menuitem> tag's app attribute. Avoid reassigning the Ctrl+F9 and Ctrl+F10 shortcuts (Windows) and the Cmd+F9 and Cmd+F10 shortcuts (Macintosh) because they are used in Dreamweaver UltraDev to open the Server Behaviors and Data Bindings panels.

You can export the current shortcut set using the Export Set as HTML icon in the Keyboard Shortcuts dialog box. The exported HTML file displays all menu commands, including those with keyboard shortcuts. The document can be printed from your browser or printed from Microsoft Word. Search for "Keyboard Shortcut Matrix" in the Dreamweaver Help (F1) to find unused keyboard shortcut combinations.

The Rename Set icon (see Figure 19-1) renames the currently selected custom keyboard set but does not permit you to rename a factory set. The Delete Set icon does not delete the current keyboard set; rather, it displays the Delete Set dialog box, which lists keyboard sets that can be deleted. Factory sets cannot be deleted, so they are not shown in the list. The currently active set cannot be deleted either, so switch to another set before attempting to delete the set currently in use.

Custom keyboard shortcut sets are stored in .xml files in the Dreamweaver4/Configuration/Menus/CustomSetsfolder. To share your keyboard shortcuts with others, copy the corresponding .xml files to the correct folder on another computer.

19.2.3 Keyboard Shortcuts in the menus.xml File

You can also modify keyboard shortcuts by editing the menus.xml file directly. Earlier, we saw how to define keyboard shortcuts using the key attribute of a <menuitem> tag. The menus.xml file also defines keyboard shortcuts using the <shortcutlist> and <shortcut> tags as shown in Example 19-2.

Example 19-2. Sample keyboard shortcut definitions
<shortcutlist id="DWMainWindow">
  <shortcut key="Cmd+Shift+Z" file="Menus/MM/Edit_Clipboard.htm" 
    arguments="'redo'" id="DWShortcuts_Edit_Redo" />
  <shortcut key="Opt+BkSp"    file="Menus/MM/Edit_Clipboard.htm" 
    arguments="'undo'" id="DWShortcuts_Edit_Undo" />
  <shortcut key="Opt+F4" command="dw.quitApplication(  )" 
    name="Quit Application" id="DWShortcuts_Main_Quit" />
  <shortcut key="Cmd+U" command="dw.showPreferencesDialog(  )"
    id="DWShortcuts_Edit_Preferences" />
  <shortcut key="Cmd+Right" file="Menus/MM/Accelerators_Main.htm" 
    arguments="'right', false" name="Go to Next Word" 
    id="DWShortcuts_Main_CmdRight" />
</shortcutlist>
19.2.3.1 The <shortcutlist> tag

The <shortcutlist> element is used to define a group of keyboard shortcuts. It has three attributes:

id (required)

The required shortcut list id must identify each shortcut list uniquely and should match the id of the corresponding menu bar or contextual menu with which the shortcuts are associated. Do not change the ids of the built-in shortcuts lists—DWMainWindow, DWMainSite, DWTimelineContext, and DWHTMLContext—as doing so prevents them from working.

app

Specifies whether to enable the shortcut list in dreamweaver (Dreamweaver) or ultradev (UltraDev) only. If this attribute is omitted, the shortcuts list is available in both applications.

platform

Specifies whether to enable the shortcut list on either mac (Macintosh) or win (Windows) only. If this attribute is omitted, the shortcuts list is available on both platforms.

The <shortcutlist> tag can contain one or more <shortcut> tags. It can also contain one or more comments of the form <!-- -->.

19.2.3.2 The <shortcut> tag

The <shortcut> element identifies an individual keyboard shortcut that is associated with a Dreamweaver command or menu item. Eight attributes can be set for a <shortcut> element:

id (required)

The required shortcut id must identify each shortcut uniquely. If you add a shortcut, ensure that its id doesn't match the id of existing shortcuts. Do not change the id s of built-in shortcuts, as doing so prevents them from working.

name

The shortcut name, such as "Open", appears in the Keyboard Shortcuts dialog box for the benefit of users. Dreamweaver identifies shortcuts by id, not name, but you should provide a meaningful name as well.

key

Specifies the key combination for this shortcut as described earlier in Section 19.1.1.2.

app

Specifies whether to enable the shortcut in dreamweaver (Dreamweaver) or ultradev (UltraDev) only. If this attribute is omitted, the shortcut is available in both applications.

platform

Specifies whether to enable the shortcut on either mac (Macintosh) or win (Windows) only. If this attribute is omitted, the shortcut is available on both platforms.

command

Specifies a JavaScript command that is executed when this keyboard shortcut is used. A shortcut must include either a file or command attribute.

file

Specifies an HTML file that controls the function of the keyboard shortcut, as described earlier in Section 19.1.1.2.

arguments

Provides a comma-separated list of arguments passed to the file specified by the file attribute. Enclose string arguments within single quotes (') inside the double quotes used to delimit the attribute's value, such as arguments="'right', false" (see Example 19-2).

A <shortcutlist> can contain as many <shortcut> elements as desired. Save the menus.xml file changes in your text editor and then restart Dreamweaver for the changes to take effect.

    Previous Section Next Section