I have 5 nodes in my VirtualStringTree:
Node #4 has no caption and should be skipped when the user presses VK_DOWN or VK_UP.
It should also not get selected when the user clicks on it.
I wrote this code (that works) to skip said node when using the keyboard:
if Key = VK_DOWN then
begin
node := VirtualTree.GetNext(VirtualTree.FocusedNode);
if not Assigned(node) then Exit;
data := VirtualTree.GetNodeData(node);
if data^.Caption = '' then
begin
VirtualTree.GetNext(node);
VirtualTree.FocusedNode := node;
VirtualTree.Selected[node] := true;
end;
end
else if Key = VK_UP then
begin
node := VirtualTree.GetPrevious(VirtualTree.FocusedNode);
if not Assigned(node) then Exit;
data := VirtualTree.GetNodeData(node);
if data^.Caption = '' then
begin
VirtualTree.GetPrevious(node);
VirtualTree.FocusedNode := node;
VirtualTree.Selected[node] := true;
end;
end;
The problem is that the node still gets focused by clicking on it.
I tried disabling the node VirtualTree.IsDisabled[node] := true;
- but no luck.
Anyone knows a way to accomplish this?
Handle the OnFocusChanging
event and return False to the Allowed
parameter for the node of your choice.