Search code examples
delphidelphi-xe5

How to make a VirtualTreeView's Node allow TMemo like multiline keyboard input instead of the TEdit like default behavior?


I am modifying the MultilineDemo that comes with VirtualTreeView's git folder (Virtual-TreeView-master\Demos\Advanced). I have just removed the multiline 'display' code and added code to the VST's onClick handler to make the clicked node editable.

I want to enter multiline text into a node like TMemo but, the enter or shift+enter key presses finish the editing. See the image below. I couldn't find a keypress event for a node in VST property panel for modifying the default behavior. My goal is to have a tree like control with nodes capable of multiline input

I don't think I have to post any code from my current application.

Default TEdit like behavior of a node in Virtual Tree View


Solution

  • You need to implement your own IVTEditLink editor, create a memo control and handle its key down event. See the /Demos/Advanced/Editors.pas unit for vtMemo type of values. It does almost what you want. It shows how to create a memo control as a node editor and how to handle the editor's control key down event (in this case the EditKeyDown method).