This topic describes the keys and mouse actions handled by a combo box control. In a simple or dropdown combo box, the edit control portion has the input focus and handles all keys not listed here, as a standard Windows edit control. In a dropdown list combo box, the static portion has the input focus. The dropdown portion never receives the input focus.
An item selected using the arrow keys, Home, End, PgUp or PgDn becomes the selected item immediately and the SFTBOXN_SELCHANGE notification is sent, whether the dropdown portion is shown or not. If the fSelectEnabledItemsOnly member of the SFTBOX_CONTROL structure is set, disabled items are skipped.
| Dropdown List Combo Box - Keys | |
|---|---|
| Down Arrow | Selects the next item. If the extended user interface is used (see SetExtendedUI) and the dropdown portion is hidden, the dropdown portion is shown instead. |
| Up Arrow | Selects the previous item. |
| Left Arrow | If the selected item is expanded, the SFTBOXN_LBUTTONDOWN_BUTTON notification is sent, so the application can collapse the item (GetExpandCollapseIndex returns the item index). Otherwise the parent item is selected, if there is one. If the Shift or Control key is pressed, Left Arrow is equivalent to Up Arrow. |
| Right Arrow | If the selected item is expandable and not expanded, the SFTBOXN_LBUTTONDOWN_BUTTON notification is sent, so the application can expand the item (GetExpandCollapseIndex returns the item index). Otherwise the first dependent item is selected, if there is one. If the Shift or Control key is pressed, Right Arrow is equivalent to Down Arrow. |
| Home | Selects the first item. |
| End | Selects the last item. |
| PgDn | If the dropdown portion is shown, the selection moves down by the number of items shown in the dropdown portion. If the dropdown portion is hidden, the next item is selected. |
| PgUp | If the dropdown portion is shown, the selection moves up by the number of items shown in the dropdown portion. If the dropdown portion is hidden, the previous item is selected. |
| F4 | Shows or hides the dropdown portion. When hiding, the current selection is accepted. If the extended user interface is used (see SetExtendedUI), the F4 key is ignored. |
| Alt+Down Arrow Alt+Up Arrow | Shows or hides the dropdown portion. When hiding, the current selection is accepted. |
| Enter | If the dropdown portion is shown, the current selection is accepted (SFTBOXN_SELENDOK) and the dropdown portion is hidden. Otherwise the key has no effect. |
| Escape | If a mouse action such as resizing the dropdown portion is in progress, it is canceled. Otherwise, if the dropdown portion is shown, it is hidden (SFTBOXN_SELENDCANCEL). A temporary selection made by moving the mouse cursor is discarded and the previously accepted item is selected again (no item is selected if none was accepted before). Otherwise the key is not used by the combo box. |
| Typed Characters | The characters are used to locate and select an item, based on the search mode (see SetEditSearchMode and Searching and Autocomplete). While the dropdown portion is hidden, the item found becomes the selected item immediately (SFTBOXN_SELCHANGE). If the fAutoDropOnInput member of the SFTBOX_CONTROL structure is set, the dropdown portion is shown. |
| Shift+F10 | The SFTBOXN_CONTEXTMENU_KBD_STATIC notification is sent (see Context Menu). |
| Simple and Dropdown Combo Box - Keys | |
| Down Arrow | Selects the next item. In a dropdown combo box using the extended user interface (see SetExtendedUI), the dropdown portion is shown instead if it is hidden. |
| Up Arrow | Selects the previous item. |
| Control+Home | Selects the first item. Without the Control key, the Home key is handled by the edit control. |
| Control+End | Selects the last item. Without the Control key, the End key is handled by the edit control. |
| PgDn | In a simple combo box and in a dropdown combo box with the dropdown portion shown, the selection moves down by the number of items shown in the dropdown portion. If the dropdown portion is hidden, the next item is selected. |
| PgUp | In a simple combo box and in a dropdown combo box with the dropdown portion shown, the selection moves up by the number of items shown in the dropdown portion. If the dropdown portion is hidden, the previous item is selected. |
| F4 | Dropdown combo box only. Shows or hides the dropdown portion. When hiding, the current selection is accepted. If the extended user interface is used (see SetExtendedUI), the F4 key is ignored. |
| Alt+Down Arrow Alt+Up Arrow | Dropdown combo box only. Shows or hides the dropdown portion. When hiding, the current selection is accepted. |
| Enter | Dropdown combo box only. If the dropdown portion is shown, the current selection is accepted (SFTBOXN_SELENDOK) and the dropdown portion is hidden. Otherwise the key is not used by the combo box. |
| Escape | If a mouse action such as dragging text or resizing the dropdown portion is in progress, it is canceled. Otherwise, if the dropdown portion of a dropdown combo box is shown, it is hidden (SFTBOXN_SELENDCANCEL). A temporary selection made by moving the mouse cursor is discarded and the previously accepted item is selected again (no item is selected if none was accepted before). Otherwise the key is not used by the combo box. |
| Backspace Delete | Handled by the edit control. With the search modes SFTBOX_SEARCH_AUTOCOMPLETE and SFTBOX_SEARCH_AUTOCOMPLETE2, the text is not completed for the resulting change (see Searching and Autocomplete). |
| Typed Characters | Handled by the edit control. As the text changes, the combo box searches for a matching item based on the search mode (see SetEditSearchMode and Searching and Autocomplete). If the fAutoDropOnInput member of the SFTBOX_CONTROL structure is set, the dropdown portion is shown. |
| Shift+F10 | The SFTBOXN_CONTEXTMENU_KBD_EDIT notification is sent (see Context Menu). Unless canceled by the application, the popup menu of the edit control is displayed. |
| All Combo Boxes - Mouse | |
| Dropdown Button | Clicking the dropdown button with the left mouse button shows the dropdown portion, or hides it if it is currently shown. When hiding, the current selection is accepted. If the combo box has no items, the dropdown portion cannot be shown. |
| Static Portion | Clicking the item displayed in the static portion of a dropdown list combo box with the left mouse button shows the dropdown portion, or hides it if it is currently shown. When hiding, the current selection is accepted. The click is reported using a notification such as SFTBOXN_MAIN_NOTIFICATION(SFTBOXN_LBUTTONDOWN_CELL). Column headers shown in the static portion can be clicked, resized and reordered as in the dropdown portion. |
| Edit Control Portion | Mouse actions are handled by the edit control (caret position, text selection). If dragging is enabled for the edit control portion (see SetDragType), the selected text can be dragged. |
| Dropdown Portion - Mouse Movement | Dropdown and dropdown list combo boxes only. If the fCursorSelect member of the SFTBOX_CONTROL structure is set (the default), the item under the mouse cursor is selected temporarily as the mouse cursor moves over the items. Disabled items are skipped if the fSelectEnabledItemsOnly member is set. |
| Dropdown Portion - Left Mouse Button | Clicking an item selects the item (SFTBOXN_SELCHANGE). In a dropdown or dropdown list combo box, the selection is accepted (SFTBOXN_SELENDOK) and the dropdown portion is hidden when the mouse button is released. The dropdown portion remains shown if the click is on a column header, the row/column header, an expand/collapse button or the tree lines, on a disabled item if the fSelectEnabledItemsOnly member of the SFTBOX_CONTROL structure is set, or if the application sets the fAllowNextRollup member to FALSE while handling the mouse click notification. Each click is reported using a notification such as SFTBOXN_LBUTTONDOWN_TEXT. |
| Dropdown Portion - Sizing Box | Dragging the sizing box (see SetSizeBox) resizes the dropdown portion. |
| Right Mouse Button | A context menu notification is sent to the parent window (see Context Menu). The dropdown portion remains shown. |
| Mouse Wheel | Scrolls the dropdown portion vertically, or horizontally if the Shift key is pressed. The selection does not change. |
| Losing the Input Focus | When the combo box loses the input focus, the dropdown portion of a dropdown or dropdown list combo box is hidden (SFTBOXN_SELENDCANCEL). A temporary selection made by moving the mouse cursor is discarded and the previously accepted item is selected again (no item is selected if none was accepted before). |
Before a key or character is processed, the combo box sends a WM_NOTIFY message to its parent window with the notification code NM_SFTBOX_KEYDOWN_CODE (structure NM_SFTBOX_KEYDOWN), NM_SFTBOX_KEYUP_CODE (structure NM_SFTBOX_KEYUP) or NM_SFTBOX_CHAR_CODE (structure NM_SFTBOX_CHAR). The fEdit member is TRUE if the key was typed in an edit control portion. If the application sets the fHandled member to TRUE, the key or character is not processed by the combo box, nor by its edit control.
In a dialog, a simple or dropdown combo box processes the Enter and Escape keys only while the dropdown portion of a dropdown combo box is shown. Otherwise these keys are available to the dialog (default button, cancel). A dropdown list combo box always processes the Enter key, so the Enter key does not reach the dialog's default button while the combo box has the input focus. It processes the Escape key only while its dropdown portion is shown or a mouse action is in progress. The Tab key is not used by the combo box.