Keyboard, hotkeys and incremental search

Virtual Tree View

Virtual Treeview handles most of the important keyboard actions on its own. Also here you can inject your own handling to modify the control's behavior. Read also about incremental search and how it is implemented.

Description

Particularly key navigation is implicitly handled in various ways. A full list of hot keys currently supported by the tree view is shown below. Note that the control key has precedence over the shift key if both are pressed at the same time. This means that in this case the shift key has no meaning. 

 

The tree view supports the same hot keys as the Windows system tree control and allows to customize key messages to change the meaning of the particular key (see also OnKeyAction). Generally speaking all navigation keys change the current selection if no modifier key (like control or shift) is pressed together with the navigator key. Like the system tree control Virtual Treeview allows to modify the current selection by holding down the shift key and pressing home, page up or any other of those keys at the same time. The control key neither changes the selection nor the focused node but can be used to scroll the tree window. 

 

For special handling a grid mode is supported (see toGridExtensions in Options) which changes (among other things) some key semantics. These changes are explicitly marked in the table below. 

 

Key 
Modifier 
Function 
Home 
none 
Selects the first visible node (the focused column does not change). This node also receives the input focus.
Modifications in grid mode: The focused node does not change but the first visible column is focused instead. 
 
shift 
Moves the focus to the first visible node (the focused column does not change) and includes every visible node, from the previously focused to the newly focused one, into the current selection.
Modifications in grid mode: Not the focused node is changed but the first visible column is focused instead. The selection does not change (note: you cannot select several columns of the same node). 
 
control 
Scrolls the tree to the top left corner without change of any selection or focused state. 
End 
none 
Selects the last visible node (the focused column does not change). This node also receives the input focus.
Modifications in grid mode: The focused node does not change but the last visible column is focused. 
 
shift 
Moves the focus to the last visible node (the focused column does not change) and includes every visible node, from the previously focused to the newly focused one, into the current selection.
Modifications in grid mode: Not the focused node is changed but the last visible column is focused instead. The selection does not change. 
 
control 
Scrolls the tree to the bottom right corner without change of selection or focused node. 
Prior
(page up) 
none 
Scrolls the tree window and single selects a node one page up. This node receive also the current focus. 
 
shift 
Like without modifier key but includes a page of nodes into the current selection. 
 
control 
Scrolls the tree window one page up without change of selection or focused node. 
Next
(page down) 
none 
Same as prior but one page down instead. 
 
shift 
Same as prior but one page down instead. 
 
control 
Same as prior but one page down instead. 
Up 
none 
Advances the focus from the currently focused node to the previous visible node. 
 
shift 
Advances the focus and adds the newly focused node to the current selection. 
 
control 
Scrolls the tree window one line up. One line is defined as the DefaultNodeHeight. 
Down 
none 
Same as up but one line down instead. 
 
shift 
Same as up but one line down instead. 
 
control 
Same as up but one line down instead. 
Left 
none 
Moves the focus to the parent of the currently focused node and selects it if the current node does not have children or is already collapsed. Otherwise the focus is not changed but the node will be collapsed. In both cases the focused node will be the only selected node afterwards.
Modifications in grid mode: If extended focus is enabled (see toExtendedFocus in Options) then the behavior changes to a simple navigation to the previous visible column. 
 
shift 
In opposition to the none-modifier case the expand state of the node does not matter nor is it changed. The focus is advanced in any case and sibling nodes as well as the parent node are added to the current selection. 
 
control 
The tree window is scrolled to the left by the amount pixel given in the indent property. 
Right 
none 
Moves the focus to the first child node of the currently focused node and selects it if the current node has children and is already expanded. Otherwise the focus is not changed but the node will be expanded. In both cases the focused node will be the only selected node afterwards.
Modifications in grid mode: If extended focus is enabled (see toExtendedFocus in Options) then the behavior changes to a simple navigation to the next visible column. 
 
shift 
Same as the none-modifier case but the selection is extended with the first child node. 
 
control 
Same as left but the tree window is scrolled to the right. 
Back 
none 
Moves the focus to the parent of the currently focused node and selects it as only node. 
 
shift 
Modifier keys have no meaning for this case. 
 
control 
Modifier keys have no meaning for this case. 
Tabulator 
none 
The tabulator key is a bit special because it is only used with grid extensions to advance from cell to cell. Without modifier the focus changes from left to right and from top to bottom. It is necessary that you enable TAB support by setting property WantTabs to True. 
 
shift 
Same as without modifier key but the focus advances backwards, from right to left and bottom to top. 
 
control 
This modifier has no effect. 
F1 
none 
This function key triggers node specific help support. Via the OnGetHelp event the application is queried for a help context to show. 
 
shift 
This modifier has no effect. 
 
control 
This modifier has no effect. 
F2 
none 
This function key turns the tree view into edit mode if there is a focused node, the tree is editable and the application allows to edit the node. 
 
shift 
This modifier has no effect. 
 
control 
This modifier has no effect. 
+
(add) 
none 
Expands the currently focused node. 
 
shift 
This modifier alone has no effect, but see the following comment. 
 
control 
Pressing the control key together with + will start auto sizing all columns in the tree. If the shift key is also pressed then the whole tree is expanded instead. 
-
(subtract) 
none 
Collapses the currently focused node. 
 
shift 
This modifier alone has no effect, but see the following comment. 
 
control 
Pressing the control key together with - will restore all columns to their previous widths. If the shift key is also pressed then the whole tree is collapsed instead. 
*
(multiply) 
none 
Expands the currently focused node and all its children and grand children. 
 
shift 
This modifier has no effect. 
 
control 
This modifier has no effect. 
/
(divide) 
none 
Collapses the currently focused node and all its children and grand children. 
 
shift 
This modifier has no effect. 
 
control 
This modifier has no effect. 
Escape 
none 
Stops actions which require a specific state in the tree like editing, mouse selecting, drag'n drop etc. 
 
shift 
This modifier has no effect. 
 
control 
This modifier has no effect. 
Space 
none 
Used only if check support is enabled (see toCheckSupport in Options) and the currently focused node has got a check type other than ctNone. In this case the space key switches the check state. 
 
shift 
This modifier has no effect. 
 
control 
This modifier has no effect. 
Apps
(menu key) 
none 
Similar to F1 triggers the apps key popup menus on a node by node basis. For more information see also the event OnGetPopupMenu. 
 
shift 
This modifier has no effect. 
 
control 
This modifier has no effect. 
none 
This is the only "normal" character used as hotkey so far. It has only an effect together with the control key. 
 
shift 
This modifier has no effect. 
 
control 
Pressing 'A' together with the control key will select all currently visible nodes in the tree view. 

 

Incremental search

Incremental search is a commonly used term to describe the effect that the user types some letters while the tree view has the focus and the control will try to locate a node whose caption matches the letters. Because Virtual Treeview does not know what caption a node has it cannot compare the incoming letters and uses therefore again an event to ask the application to do the comparison. By using the lesser of both string lengths and a partial comparison in this event the tree will be able to select also partial matches. Note: Virtual Treeview tries to mimic the UI of the system list view and system tree view as close as possible and uses therefore two modes when searching. One is used when there is no key or only one key pressed and the new key is the same as the already recorded one. In this case the search always starts with the next node and only nodes which match the single new key will be found. This allows to quickly cycle through a number of nodes all matching/beginning with the same letter. The other mode is normal linear search where all key presses are recorded and compared with the nodes in the tree. Whenever the application considers a node as match (it even hasn't to have a caption the same as the search string) this node is returned as new target and focused.

Group
Links
What do you think about this topic? Send feedback!