OnChange vs OnEditingDone lazarus / 31-LCL ---------------------------------------------------------------------- Weitentaaal · 2022-02-11 09:25 Hello, I run into following Problem: Example: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i  procedure MyClass.Text1Change(Sender: TObject);begin   TreeHeight:= Str2Float(Text1.Text);end; procedure MyClassViewModel.SetTreeHeight(AValue: Boolean);begin   if fTreeHegiht=AValue then Exit;   if fTreeHegiht < TreeMinHeight then fTreeHeight:= TreeMinHeight   else fTreeHegiht :=AValue;    SendNotification([TreeHeightChanged]);end;   Now i want to insert 300 for Treeheight(Text1) and lets say TreeMinHeight is 200. OnChange wont let me change it to 300 because as soon as i type 3 the Text will be changed to 200 again. So i tried OnEditingDone, then the Text will only get changed when the user will press ENTER or the Control loses focus, but if he types in 190 and then presses on close form he will not know that the text changed to 200 again because its too late, and before doing so i wanted to aske the experts:). i hope you guys understood what i ment. in short: OnChange adopts the change too early              OnEditingDone adopts the change too late is there any better event i missed ? any trick to overcome this problem ? i could probably combine OnEditingDone with OnExit, but then I would have to apply this to all TEdit's which would take time and maybe more memory (not sure if the program then needs more memory, just guessed u have to store more bytes -> more Memory). Tips or solutions would be very helpful thanks ! PS: Have a nice Weekend ! ---------------------------------------------------------------------- Thaddy · 2022-02-11 09:41 OnChange is triggered on ANY change.... Obviously.... If any input changes, it is triggered immediately. Any key or any mouse or whatever. And that is logical. ---------------------------------------------------------------------- Weitentaaal · 2022-02-11 09:50 Quote from: Thaddy on February 11, 2022, 10:41:46 amOnChange is triggered on ANY change.... Obviously.... If any input changes, it is triggered immediately. Any key or any mouse or whatever. And that is logical. Its logical, yes,  just wanted to ask how you deal with problems like i described. ---------------------------------------------------------------------- Thaddy · 2022-02-11 09:54 Well, OnEditingDone is only triggered when the focus changes from the control to another one. You can do that in code but how would you decide ? E.g. you can trap the enter key, but in a memo like control that would be nonsense. What you want looks like "being caught between a rock and a hard place"...(Homer, Odyssey, not Simpson) Also note the escape key should cancel the whole operation, so can not be used either.... ---------------------------------------------------------------------- Weitentaaal · 2022-02-11 10:25 i want to prevent that this happens: "but if he types in 190 and then presses on close form he will not know that the text changed to 200 again" ---------------------------------------------------------------------- Zvoni · 2022-02-11 11:02 Quote from: Weitentaaal on February 11, 2022, 11:25:32 ami want to prevent that this happens: "but if he types in 190 and then presses on close form he will not know that the text changed to 200 again" I don't understand this. If he clicks on the Close-Button, the Edit-Field loses its Focus and triggers OnExit Why would you like to inform the User, that it's 200 again instead of 190? Value-Constraints are there for a reason ---------------------------------------------------------------------- jamie · 2022-02-11 14:43 The MODIFIED property is your friend. Clear it when form recives focus per edit control . At some point like when the form closes you can test the modified property.  This property gets set when user changes content but not when code changes content.  This allows you to update actual user changes.  Have a good day.