Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectedCount is not always correct #1197

Open
BigAl66 opened this issue May 24, 2023 · 1 comment
Open

SelectedCount is not always correct #1197

BigAl66 opened this issue May 24, 2023 · 1 comment
Labels
Bug Pull Requests Invited There are no current plans to address the issue, but we would be happy if someone supplies a PR.

Comments

@BigAl66
Copy link

BigAl66 commented May 24, 2023

procedure TMyForm.vstStateChange(Sender: TBaseVirtualTree; Enter, Leave: TVirtualTreeStates);
var
  SelectedCount: Integer;
begin
  if tsChangePending in Leave then
  begin
    SelectedCount := 0;
    for var Node in vst.SelectedNodes do
      Inc(SelectedCount);
    if SelectedCount <> vst.SelectedCount then
      raise Exception.CreateFmt('counted=%d, vst=%d ', [SelectedCount, vst.SelectedCount]);
  end;
end;

Of course, multiselect is active. The code above throws an exception when I reduce the number of selected Items with <cursor up/down>. In that case the vst.SelectedCount still holds the old number while the counted items (SelectedCount) is correct.

If I check vst.SelectedCount later, it seems to be correct again. However, I can't find any later event fired by the vst component to check the count and respond to it.

OnAddToSelection and OnRemoveFromSelection don't work either. Again, the vst.SelectedCount is wrong.

It would be great to have an "OnAfterSelect" event that fires when everything is ready...

@BigAl66 BigAl66 changed the title Bug: SelectedCount is not always correct SelectedCount is not always correct May 24, 2023
@joachimmarder
Copy link
Contributor

I can confirm the issue, but I don't have a good solution at the moment.

@joachimmarder joachimmarder added Bug Pull Requests Invited There are no current plans to address the issue, but we would be happy if someone supplies a PR. labels Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Pull Requests Invited There are no current plans to address the issue, but we would be happy if someone supplies a PR.
Projects
None yet
Development

No branches or pull requests

2 participants