Q: TTMSFNCComboBox possible to react on cursor in list?

I am using TTMSFNCComboBox in a multiplattform app. When the combo box is dropped down, the user can walk through the list of items in the dropped down list by pressing cursor keys on the keyboard.

Is there a way to see which item is the active one in the dropped down listbox and when that changes (when the user uses csr-up or csr-down)?


Normally it should be highlighted by default. In order to be able to investigate this, we'll need the following:

  • Which IDE version are you using?
  • Which platform is affected?

If you can, please provide a sample too.

Sure, it is highlighted, and meanwhile I discovered the items are displayed in a TTMSFNCTreeView Subcomponent which is accessable through the PopUp field.

More specifically my question was about how to get notified when the user uses the cursor keys to walk / scroll through the items / nodes. (I was not complaining about a bug - sorry for my bad description)

Indeed TTMSFNCTreeView is used for the list.

Depending on your TTMSFNCComboBox.Style setting you can assign the OnKeyDown events for either the TTMSFNCTreeView or the TEdit control.

  • csDropDown: In this case the TEdit is always in focus with keyboard navigation so key down events are processed from this control. You can assign your own OnKeyDown event via TTMSFNCComboBox.Edit, but you'll need to save the previous OnKeyDown event and call it from your implementation to not break functionality:
procedure TForm1.FormCreate(Sender: TObject);
  FPrevOnKeyDow:= TMSFNCComboBox1.Edit.OnKeyDown;
  TMSFNCComboBox1.Edit.OnKeyDown := EKeyDown;

procedure TForm1.EKeyDown(Sender: TObject; var Key: Word; var KeyChar: WideChar; Shift: TShiftState);
  FPrevOnKeyDow(Sender, Key, KeyChar, Shift);
  Log.d('Key is pressed');
  • csDropDownList: This is more simple, just use the OnKeyDown event of the TTMSFNCTreeView. We don't utilize this event in TTMSFNCComboBox so there won't be any conflicts.

Thanks, came up with this alternative approach:

uses FMX.TMSFNCTreeView, FMX.TMSFNCTreeViewData;

procedure TmyForm.MyComboBoxPopup(Sender: TObject);
  // set OnAfterSelectNode EventHandler in Treeview of MyComboBox
  (MyComboBox.Popup.ContentControl.Controls[0] as TTMSFNCTreeView)
    .OnAfterSelectNode := AfterSelectNode;

procedure TmyForm.MyComboBoxClosePopup(Sender: TObject);
  // reset EventHandler
  (MyComboBox.Popup.ContentControl.Controls[0] as TTMSFNCTreeView)
    .OnAfterSelectNode := nil;

procedure TmyForm.AfterSelectNode(Sender: TObject; 
  aNode: TTMSFNCTreeViewVirtualNode);
  // Node has been selected by user in popped up TreeView
  // (e.g. with cursor keys)

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.