[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'ComCtrls' (#lcl)

# TCustomTreeView.EditorKeyDown

Implements the OnKeyDown event handler for the editor on the tree view control.

## Declaration

Source position: comctrls.pp line 3561

`protected procedure TCustomTreeView.EditorKeyDown(`
`Sender: TObject;`
`var Key: Word;`
`Shift: TShiftState`
`); virtual;`

## Arguments

`Sender` |  | Object for the event notification.
`Key` |  | Virtual key code for the notification.
`Shift` |  | Shift, Ctrl, or Alt modifier for the key down event.

## Description

EditorKeyDown ensures that key down events and focus change are handled for the tree node editor on the control.

Key and Shift contain the virtual key code and shift modifier(s) for the key down event. Virtual key codes handled in the method include:

Return (VK_RETURN)
  Ends editing and accepts the changed valued in the Text for the tree node in EditingItem.
Escape (VK_ESCAPE)
  Ends editing but rejects any change to the text for the EditingItem.

Shift must be an empty set ([]) to handle these virtual key codes in the method.

EditorKeyDown calls EndEditing to update state flags, and to signal assigned OnEdited and OnEditingEnd events handlers when the Text for the tree node is changed. It calls SetFocus to restore focus to the tree view control if the tree node editor was assigned and had focus on entry to the method.

The value in Key is set to 0 to if the virtual key code is handled in the method.

EditorKeyDown is used as the OnKeyDown event handler for the internal TEdit control created in the BeginEditing method.

## See also

TCustomTreeView.EditingItem |  | Contains the tree node being edited in the control.
TCustomTreeView.EndEditing |  | Updates the specified tree node and hides editor.
TCustomTreeView.OnEdited |  | Event handler signalled when the tree view control has been edited.
TCustomTreeView.OnEditingEnd |  | Event handler signalled when EndEditing is called for the control.
TCustomTreeView.BeginEditing |  | Prepares the control to edit the text for the specified tree node.
TTreeNode.Text |  | Text displayed for the tree node.
TEdit.OnEditingDone |  | Event handler signalled when editing is completed for the control.
TWinControl.SetFocus |  | Ensures that the control or window handle has focus.