- The incorrect information about Delphi .OnChange event (not existing) not removed. Will be just forgotten if the issue stays closed. #39914 (comment 1113492007)
- Since #39917 (closed) applied - the same changes need ot be done to https://dsiders.gitlab.io/lazdocsnext/lcl/dbctrls/tdbcheckbox.html
- The same changes need to be done for the parent class https://dsiders.gitlab.io/lazdocsnext/lcl/stdctrls/tcustomcheckbox.html
Frankly, maybe make all the changes in that very tcustomcheckbox documentation once, and ley all the four derived controls just inherit the change in docs, like they inherited the change in the code?
My LCL patch sems to be approved, working on Win32 native and Linux GTK2. Unless later some critical bug would be found on other toolkits forcing rollback, it probably would make it into 2.3 release.
If it will the documentation would have to be changed https://lazarus-ccr.sourceforge.io/docs/lcl/stdctrls/tcustomcheckbox.html
The proposal, from the horse's mouth.
Create the page for
public class var TCustomCheckBox.VCL_OnClick_Emulation: boolean;. This page would describe both the variable and the
Create the pages for
TCustomCheckBox.OnChangeto override inherited ones. Those pages should just redirect to the page above.
The proposed text would be something like this:
TCustomCheckBox.VCL_OnClick_Emulation variable determines if
TCheckBox.OnClick event follows Delphi rules, or works in new LCL mode. By default the variable is
True selecting the legacy mode, and developers can switch it to
False any time to get the new behavior. The switch is made for the whole application, there is no way to make different button controls have different behavior.
If the legacy Delphi mode is selected, then
OnClick event handler is called every time that
TCustomCheckBox.State is changed. It can happen following a user's action, like clicking the control with mouse, or hitting the spacebar on a keyboard when the control is focused. It can also happen when developer executes commands like
CheckBox1.Checked := True; or some library does. The event is only fired if the actual change of the state happenned, for example if a user clicks
TRadioButton many times the event handler would only be called when the button transits to selected state, consequent clicks on the already selected button would not result in more event handler calls.
OnChange event in the legacy mode has the same semantics and would be fired immediately before calling
OnClick. This provides for developers migrating their applications from Delphi to gradually rework their code preparing for the behavior switch.
In the new LCL mode, chosen by
TCustomCheckBox.VCL_OnClick_Emulation := False;, the events have different semantics.
OnChange event handler in the new mode is called every time the state of the control changes, whenever the change was caused by user action or by program code.
OnClick event handler in this mode is called every time the user activates the button control by mouse, by keyboard or by any other user action the operating system considers equal to clicking, whenever this action made the control change it state or not.