Forum > LCL

TCheckbox.Checked should trigger onClick?

<< < (2/2)

jamie:

--- Quote from: bdexterholland on September 01, 2022, 04:59:43 pm ---
--- 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.

--- End quote ---

 You may not like it but, the GODS at the helm dictate that the LCL should reproduce all of Delphis Bugs.

 So all you have left is to use an extra feature of the control to work around that and that would be the "MODIFIED" property.

 Even Delphi has a couple of controls with that property just for the same reason.

VTwin:
It seems weird to me, but apparently it is supposed to. ComboBox as well. I thought I found a bug in the Mac widget set, but I has informed by Dimitri that it was a bug if it did not fire. Implementation across widget sets seems inconsistent, but you need to expect it.

I have large preferences dialogs that have complex Get and Set routines. Prior to setting I set a global flag (fIsSetting) to make sure that setting a ComboBox in code does not trigger an undesired event.

jamie:
I just went in and recompiled that Control with a MODIFIED property.

The DOChange(Var Msg) message LM_CHANGE; handler only gets called when user actually makes changes, otherwise a software change does not trigger this.

  In that event, I set the MODIFIED property to TRUE.

  I made a little change in the CHECKED property to clear the MODIFIED property since it appears using that does not trigger the LM_CHANGE handler.

 With this in mind, The control still behaves the same as it did before with the acceptation of that it now sets the MODIFIED property which can be viewed while in the OnClick or OnChange etc.

 This was just an experiment, but it seems to work and follows suite of other controls that uses this same approuch.

 Bye. ;D

Arioch:
Funny how you are into it too.

Hopefully there would be an opt-out via

class var TCustomCheckBox.VCL_OnClick_Emulation: boolean  (which is not a very nice name, and if something would come with better name - i am all ears).

Default however would be Delphi-compatibility which always was like this (VCL TCheckBox never had OnChange or OnEditingDone or similar)

There were strong opinions both for and against Delphi behaviour, so both ways would be implemented.

Preliminary green light was given at https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/39870#note_1092375512

Navigation

[0] Message Index

[*] Previous page

Go to full version