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

Button clicks lost if node is being edited #1290

Open
mpfj opened this issue Jan 23, 2025 · 4 comments
Open

Button clicks lost if node is being edited #1290

mpfj opened this issue Jan 23, 2025 · 4 comments
Labels
Open for Discussion There are several possibilites to address the issue and anyone is invited for comments.

Comments

@mpfj
Copy link

mpfj commented Jan 23, 2025

Delphi 12.2
VTV - current git master

If you are editing a node in the tree and you click away from that edit box onto (say) a standard button, the edit box closes but the button click never occurs.

This is contrary to how the standard Win32 treeview works ... this closes the edit box, applies the new text and then also clicks the button (which is how myself and my colleagues perceive the control should work).

To demonstrate this:-

  • Load up, compile and run the "Minimal" demo
  • Click on the first node "Level 0, Index 0"
  • Press F2 to enter Edit Mode
  • Now click the "Clear tree" button at the bottom

You will see that the edit box closes but the tree is not cleared.
Somewhere the "click the button" message is being lost when the edit box closes.

@joachimmarder
Copy link
Contributor

This is contrary to how the standard Win32 treeview works

I cannot confirm this. I just tried this in the File-Open-Dialog of Delphi, both with the treeview and the listview: Selecting an element, pressing F2 and then clicking the Open or Cancel button does nothing. I am on Windows 11. Can you confirm this?

@joachimmarder joachimmarder added the Open for Discussion There are several possibilites to address the issue and anyone is invited for comments. label Jan 30, 2025
@mpfj
Copy link
Author

mpfj commented Jan 30, 2025

No, when I using the following code, I get a TreeView on which I can double-click the nodes to start editting the text.
Once in edit mode, you can click the Button and the message box pops up.

This is not how VTV seems to work ... the Button press is ignored until the edit has finished so you have to click twice.

Unit1.dfm

object Form1: TForm1
  Left = 0
  Top = 0
  Caption = 'Form1'
  ClientHeight = 441
  ClientWidth = 624
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -12
  Font.Name = 'Segoe UI'
  Font.Style = []
  TextHeight = 15
  object TreeView1: TTreeView
    Left = 224
    Top = 96
    Width = 257
    Height = 225
    Indent = 19
    TabOrder = 0
    OnDblClick = TreeView1DblClick
    Items.NodeData = {
      070200000009540054007200650065004E006F00640065002F00000000000000
      00000000FFFFFFFFFFFFFFFF0000000000000000000100000001083000390038
      00370030003900380037000000270000000000000000000000FFFFFFFFFFFFFF
      FF00000000000000000000000000010471007100710071000000370000000000
      000000000000FFFFFFFFFFFFFFFF00000000000000000000000000010C300039
      003800370030003900380037003000390038003700}
  end
  object Button1: TButton
    Left = 72
    Top = 304
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 1
    OnClick = Button1Click
  end
end

Unit1.pas

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    TreeView1: TTreeView;
    Button1: TButton;
    procedure TreeView1DblClick(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
    MessageBox(Form1.Handle, 'Hello', 'Goodbye', MB_OK);
end;

procedure TForm1.TreeView1DblClick(Sender: TObject);
begin
	TreeView1.Selected.EditText;
end;

end.

@joachimmarder
Copy link
Contributor

Have you tried in the File-Open-dialog?

@mpfj
Copy link
Author

mpfj commented Jan 30, 2025

Yes and, as you say, the OK and Cancel clicks are ignored until the edit box is ended.

So I guess what I'm asking is which behaviour is "correct" ?
As with many things Windows based, nothing is consistent :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Open for Discussion There are several possibilites to address the issue and anyone is invited for comments.
Projects
None yet
Development

No branches or pull requests

2 participants