Manipulating Files Using Drag and Drop

Manipulating Files Using Drag and Drop

Nearly all the file and directory operations you've learned to perform so far are accomplished using context menus. Although the context menu is certainly a powerful tool, another technique known as drag and drop is often more convenient.

To drag and drop, place your cursor over the icon of the file or directory you want to move; then click the mouse or trackball button, and hold it down as you drag the pointer and icon to the new location. Release the button to drop the item into its new location. The following sections show you how to use drag and drop in some simple file management tasks.

Moving a File into a Directory or to the Desktop

For you to be able to perform a drag-and-drop operation, both the file you want to affect and its destination must be visible on the screen. To move a file into a directory using drag and drop, use the left button to drag the file's icon onto the icon or into the file manager window of the directory you want to move the file into. Then release the button to drop the file into its new location.

You also can use drag and drop to move files and directories to the desktop. Using the file manager, navigate until the icon for a file or directory that you want to move is visible; then click it and drag it out of the file manager window and onto the desktop. Release the mouse button to drop the file. Figure shows the results of dragging and dropping untitled folder from your home directory to the desktop. You can use the same drag-and-drop process to move files and directories from the desktop back into a file manager window or into directories displayed there.

Figure. The directory untitled folder has been dragged and dropped onto the desktop. Files can be stored in it as in any other directory.

Can You Delete a File by Dragging It to the Trash Icon?

Files or directories can also be moved into the Trash (thrown away) using this technique. Simply drag the file you want to throw away onto the Trash icon. When the Trash icon is highlighted, release the button, and the file in question will be placed in the Trash.

Using Context Drag and Drop

If you have a three-button mouse or pointing device, you can also use an operation called context drag to move, copy, and link files between folders using the file manager. To use this feature, drag and drop using the middle pointer button rather than the left one. When you release the middle button after dragging an icon to a new location, a context menu appears for the drag-and-drop operation. You can choose options from this menu to perform several different tasks.

Try the context-drag operation by dragging a file to the desktop using the middle button instead of the left button of your pointing device. When you release the button, a menu similar to the one shown in Figure appears.

Figure. The context drag has been used between the file anotherfile. txt and the desktop. The context menu enables you to choose the action you want the file manager to perform on the file in question.

When you choose an option in the context menu, the selection action is performed. Here are the choices:

  • Move Here moves the file or the directory and all its contents from its original location to the location where you released the button.

  • Copy Here copies the file or the directory and all its contents from its original location to the location where you released the button.

  • Link Here creates a symbolic link in the location where you released the button pointing to the file's original location. To learn more about symbolic links, see Chapter 7.

  • Set as Background, available only when dragging image files, causes the image being dragged to be used as the wallpaper (background image) for the desktop or for the file manager window in question.

  • Cancel voids the operation; the menu will disappear and all will be as if you had never dragged the file icon from its original location.

What If You Don't Have a Middle Mouse Button?

Although most PC mice these days come with three buttons (or two buttons and a clickable scrollwheel), there are a few two-button-only mice in use as well.

If your mouse has only two buttons, you may be able to emulate the functionality of a middle click by using both the left and right buttons on your mouse at the same time (that is, clicking them together).

     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows