Jump to content
Sign in to follow this  
Willicious

Output from Tree View when using Arrow Keys (as well as Mouse Click)

Recommended Posts

Hi all,

 

The app I'm working on has a tree view which displays relevant info when an item in that tree is clicked with the mouse. It's also possible to scroll through the treeview list items using the arrow keys (which is obviously quicker than point-clicking every item to get the displayed info), however the info is not displayed when using the arrow keys. It's necessary to actually click an item to get it to display the info.

 

Here's the relevant procedure:

procedure TFLevelSelect.tvLevelSelectClick(Sender: TObject);
begin
  SetInfo;
end;

As you can see, SetInfo is only called when the tree view is actually clicked. Do I need to add procedures for VK_DOWN and VK_UP which call this function, or can the hotkeys be added in here somewhere?

 

Many thanks,

 

Will

Edited by Willicious

Share this post


Link to post

this help you?

procedure TForm1.TreeView1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  case Key of
    VK_UP, VK_DOWN:
      // TreeView1.OnClick(self);
      Caption := TreeView1.Selected.Text;
  end;
end;

I forgot "OnChange" works in mouse/keyboard 

procedure TForm1.TreeView1Change(Sender: TObject; Node: TTreeNode);
begin
  Caption := Node.Text;
end;

 

Edited by programmerdelphi2k
  • Thanks 1

Share this post


Link to post
On 4/27/2023 at 6:40 PM, programmerdelphi2k said:

"OnChange" works in mouse/keyboard 

 

Yes, thank you! The following code worked (i.e. setting an OnChange event for the treeview) 🙂

procedure TFLevelSelect.tvLevelSelectChange(Sender: TObject);
begin
  SetInfo;
end;

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×