How to keep editor alive in Virtualtreeview?
Asked Answered
C

1

7

I'm trying to build a simple 2 columns grid "property editor" based on VirtualTreeView.

(I want to mimic look and user experience seen on Delphi's IDE object inspector)


The component is working almost and can handle multiple editors, but I'm facing an annoying bug :

When I click on a new node (a new row), the node is selected and the editor appears, regardless of the column I've clicked on. It's expected and OK.

Then, when I click on the first column of the same row, I expect to see my editor content validated and the editor keeping focus (like in delphi's object inspector).

But the editor content is validated then it disappear and the entire node (row) is selected. The editor won't get back (even if I click on second column), until I select another node and click back on the previously selected node.

EDIT : added illustration and precision about my code.

illustration of the problem

about the code : I do not have inserted code here because I used (as a starting point) the exact same code as the one found on Advanced Demo (properties page)


What I tried and found out :

the 2003's compiled Advanced demo (properties tree page) found here seems to works like what I expect from my component (and from virtual treeview).

But when I compile this same demo (I tried with versions 4.5.2, 4.8.7 and even 5.0.0 from current trunk on google code, on both delphi 2007 and 2009) the bug reappears !

I first think there was a documented breaking change between 2003 and more recent versions, but I can't find anything. I've also played with all available options trying to solve this, but without success.

I still don't know if this problem comes from new delphi RTL or a breaking change (bug?) in virtualtreeview.

so my questions :

  • do you have the same problem when compiling Advanced demo ?
  • any tip or workaround in code to solve my problem ?

As a side note, I nearly give up with virtualtreeview this afternoon and I wanted to try a solution with another component... I found this interesting question and decided to try berg's component, but was stopped in the buying process when reading an advice on their homepage (see my comment on the related question)

Croce answered 2/6, 2012 at 0:8 Comment(3)
Is there a reason you're not using the TValueListEditor that is provided in the VCL? It's specifically designed to do what you're trying to do yourself (provide a list of keys and allow you to edit values, like the Object Inspector). It implements the behavior you're looking for by setting the KeyOptions.KeyEdit to True. It has OnGet event handlers that let you provide lists and edit masks, and has an OnEditButtonClick event that allows the ... type button.Separation
@KenWhite Good point but the only reason I can see is that I noticed [-] button to the left so Damien might possibly have collapsing capabilities, which the TValueListEditor might not have.Hourigan
Yes, I need collapsing capabilities (like in IDE's property editor). Well, I managed to approach the wanted behavior, adding WM_STARTEDITING messages in many events (onDblclick, etc.) but I still think there may be something broken in virtualtreeview (I began to look at the internals of the control and it seems that tsEditPending internal state is not handled properly)Croce
A
3

The VSTs onChange just gets called by changing the selection of nodes. The state will not change anymore, if the node is already selected. So, you have to implement a behaviour similar to Object Inspector on your own, e.g. by calling VSTs EditNode()-Method in the OnClick-Callback:

procedure TMainForm.VSTClick(Sender: TObject);
var node: PVirtualNode;
begin
  node:= VST.GetFirstSelected();
  if(node <> nil) then
    VST.EditNode(node, EDITABLE_COLUMN_INDEX);
end;
Aric answered 17/9, 2012 at 11:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.