Forum > LCL

TCheckbox.Checked should trigger onClick?

(1/2) > >>

bdexterholland:
Should TCheckbox.Checked trigger OnClick?



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---unit Unit1; {$mode objfpc}{$H+} interface uses  Forms, Dialogs, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    CheckBox1: TCheckBox;    procedure Button1Click(Sender: TObject);    procedure CheckBox1Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.CheckBox1Click(Sender: TObject);begin  ShowMessage('hello! it''s that you''re looking for?');end; procedure TForm1.Button1Click(Sender: TObject);begin  CheckBox1.Checked := not CheckBox1.Checked;end; end. 

Zath:
For the record, Delphi 11.1 does it too.

So the action of it being ticked at runtime is regarded as a button click on the control even though it wasn't.
Interesting.

Lazarus does it with the radiobutton too.

hamacker:
Lazarus 2.2.2 when change state (checkbox.state) does not trigger OnClick or OnChange, just when Checked:=[true/false].
I would prefer not trigger when change by checkbox.state, but maybe it´s not the same behavior of previous versions.


For comparation, Delphi trigger OnClick if you change state or change Checked:=[true/false].

jamie:
The control needs a MODIFIED property like a few others to report if user caused the change .
 It reports true if user changed state, otherwise false if a software change.

The value remains when the control loses focus so query of controls can be  made for an file update etc.

bdexterholland:

--- Quote from: jamie on September 01, 2022, 01:20:36 pm ---The control needs a MODIFIED property like a few others to report if user caused the change .
 It reports true if user changed state, otherwise false if a software change.

The value remains when the control loses focus so query of controls can be  made for an file update etc.

--- End quote ---

I confess I don't like that approach. It seems to me a gambiarra for a behavior that has been developed wrong because another also does wrong.

The clear example is that allowing you to change the field without clicking trigger a click event. But click does not occur in context.

Navigation

[0] Message Index

[#] Next page

Go to full version