Implements the TShortPathEdit control.

ShortPathEdit.pas implements the TShortPathEdit control, a directory edit control with a directory selection dialog.

This file is part of the LazControls package.

Control used to select a directory on the local file system.

TShortPathEdit is a TDirectoryEdit descendant which allows selecting a directory on the local file system.

TShortPathEdit provides a Directory property to specify the starting directory for its path selection dialog. If Directory is not assigned, the RootDirectory property is used instead. It differs from the ancestor class in its implementation of the CreateDialog and RunDialog methods.

An OnAcceptDirectory event handler is provided and allows the application to determine how the selected directory name is handled. The event handler can be used to process and store the value for the directory selected in the dialog.

TShortPathEdit is used in the implementation of the path editor dialog in the Lazarus IDE.

Creates and configures the dialog used to select a directory.

CreateDialog is an overridden method in TShortPathEdit used to create and configure the directory selection dialog for the control. The return value contains the TCommonDialog descendant created and configured in the method. It is actually a TSelectDirectoryDialog instance.

CreateDialog uses the value in the Directory property as the initial directory for the dialog. Directory must contain a path which exists on the local file system. If Directory is unassigned, or does not exist, the value in RootDir is used as the initial directory for the dialog.

CreateDialog assigns the value in DialogTitle as the title for the dialog.

CreateDialog is called when the RunDialog method is called after clicking on the speed button for the control.

Directory selection dialog created and configured in the method. Executes the directory selection dialog for the control.

RunDialog is an overridden method in TShortPathEdit. It is an alternate implementation, and does not call the inherited method.

RunDialog calls CreateDialog to create and configure the directory selection dialog used in the control. The Execute method in the dialog is called, and the String returned as the dialog result is captured. The OnAcceptDirectory event handler is signalled (when assigned) using the dialog result as an argument. If the dialog return value is not an empty string (''), it is assigned to the Directory property.

Initial directory used in the directory selection dialog.

Directory is a String property used to specify the initial directory on the local file system used to select a directory in the control. It is used as the initial directory for the directory selection dialog executed in the RunDialog method. It is also used to store a valid path name returned from the directory selection dialog.

A value assigned to Directory is not automatically reflected in the text for the control. Use the OnAcceptDirectory event handler to update the value in Text if desired.

Event handler signalled when a directory is selected in the directory selection dialog.

OnAcceptDirectory is TAcceptFileNameEvent property with the event handler signalled when a directory path has been selected in the RunDialog method. Arguments to the event handler include the directory name selected in the dialog, or an empty string when the Cancel button is pressed in the dialog.

OnAcceptDirectory can be used to performed actions needed when the selected directory has been changed. Value is a variable parameter, so it can be modified in the event handler prior to its storage in the Directory property. For instance, the selected directory could be converted to a path relative to the RootDir for the control. Or, the selected directory could shortened and assigned to the Text for the control.

Applications must implement and assign an object procedure to allow responding to the event notification.