[..] if it is unchecked (false) in the IDE, and I have:The Change event is triggered.
procedure TForm1.FormShow(Sender: TObject); begin CheckBox1.Checked := true; end;
I'm curious, why do you think it shouldn't? After all it's supposed to be triggered on any property change.
Or is it because you change it in code vs. user action?
However, if it is unchecked (false) in the IDE, and I have:That's expected actually.
The Change event is triggered. :(
It is my understanding, and observation, that a control should respond to a user action, and not trigger a change event if assigned a value in code. For, example, if you set a ComboBox item index in code, that should not (and does not) trigger a change event.The answer is "inconsistency".
The answer is "inconsistency".
For example in Web-browser (JS) world "onchange" is triggered due to a user action. Changing the value via the software will not trigger the event.
In Cocoa API, "onchange" is triggered due to a user action. Changing the value via the software will not trigger the event.
In WinAPI world (inherited by Delphi, inherited by LCL), changing the value triggers the same "OnChange" event as user action does.
BUT in WinAPI, there's typically a way to suppress the notification.
Yet LCL itself would send out the notification.
Most of LCL Controls would trigger the notification, either way. And the documentation should be referred to.
In case of the check box, you can avoid the notification by usinginstead of using checked property
checkbox1.State:=csChecked;
So, Lazarus is emulating the Windows/Delphi model? From my experiences (but I should test), Linux and Windows seem not to send an OnChange when set in code, while some of Carbon's did. I figured it was a Carbon bug. Maybe it is a Windows/Linux bug instead? %)I would encourage you to play around and see how (and if) things are different.
But the common rule is "follow Windows widgetset (as it is most likely does what Delphi does)", no matter if it's poor design or not.
Just for the record, but not the reference.
Delphi FMX checkbox doesn't seem to support "mixed" state at all. (so there's no "State" property, only "IsChecked")
Changing IsChecked via code triggers OnChange event, but doesn't trigger OnClick event.
Changing checked via mouse click triggers both OnChange and OnClick events.