TSpinEdit possible bug lazarus / 31-LCL ---------------------------------------------------------------------- Neville · 2021-10-02 09:28 Lazarus 2.0.12 I find that with TSpinEdit, if both MaxValue and MinValue are set to the same number, then the component acts as if no limits were present at all. It doesn't matter if the limits were set at design time, or programmatically during a run, the effect is the same. I'm aware that possibly this isn't the best place to post bug reports, but I haven't been able to fathom where and how to post the report officially. ---------------------------------------------------------------------- winni · 2021-10-02 11:14 Hi! If you want to set MaxValue and MinValue to the same there is  a solution in Pascal. It is called const No, that is not a bug. Your kind of use is nonsense. Perhaps there should be  a function to prohibit this nonsense. Winni ---------------------------------------------------------------------- Bart · 2021-10-02 11:20 Quote from: Neville on October 02, 2021, 11:28:55 amI find that with TSpinEdit, if both MaxValue and MinValue are set to the same number, then the component acts as if no limits were present at all. This is by design, it is Delphi compatible. I can see that this is not properly documented though. Bart ---------------------------------------------------------------------- Bart · 2021-10-02 11:25 Quote from: Bart on October 02, 2021, 01:20:40 pmI can see that this is not properly documented though. Please file a bugreport in our bugtracker on GitLab for the lack of documentation. I updated the text on the Wiki. Bart ---------------------------------------------------------------------- Bart · 2021-10-02 13:08 Which bugreport are you referring to? Bart ---------------------------------------------------------------------- Bart · 2021-10-02 13:49 Quote from: jamie on October 02, 2021, 03:22:41 pmit was reported before the change over.. Well, it should still have the same issue number. Bart ---------------------------------------------------------------------- wp · 2021-10-02 15:34 Quote from: jamie on October 02, 2021, 03:22:41 pmBasically the Modified property has no purpose the way it stands now. To me the current way Modified works is perfectly logical. It signals whether the Edit.Text has been changed after the time Modified has been reset to false. It is irrelevant who made the change, the user or code because I want to know whether the Edit.Text has a new value at all so that, for example, I thus must repeat a calculation which uses the Edit.Text or must resave the file in which Edit.Text is stored. The only point which is usually forgotten is to reset Modified to false after the Edit has received its initial value. ---------------------------------------------------------------------- Neville · 2021-10-02 15:49 I've got a quick fix to my original problem: function SpinValue(SE:TSpinEdit):integer; begin    if SE.MaxValue = SE.MinValue then Result := SE.MaxValue                                 else Result := SE.Value; end; ---------------------------------------------------------------------- wp · 2021-10-02 16:27 When MaxValue and MinValue are equal (the default) the result of that function does not change any more, no matter what is entered in the SpinEdit. Is this really what you want? ---------------------------------------------------------------------- Bart · 2021-10-02 20:10 Quote from: wp on October 02, 2021, 05:34:52 pmTo me the current way Modified works is perfectly logical. It signals whether the Edit.Text has been changed after the time Modified has been reset to false. It is irrelevant who made the change, the user or code AFAIK this is not how it works with TEdit: setting Text by code sets Modified to False, this is by design and Delphi compatible. I agree with Jamie (well, there's something doesn't happen very often) that it would be logical is this is the case for TSpinEdit as well. The same logic would then also mean that setting Value by code should also set Modified to False. Bart ---------------------------------------------------------------------- Bart · 2021-10-02 20:16 @Jamie: searching the bugtracker I could not find an open issue for spinedit regarding Modified property. Feel free to open a new ticket for this one (secifically for TSpinEdit(Ex), not for other controls please. Bart ---------------------------------------------------------------------- Bart · 2021-10-03 08:03 Quote from: jamie on October 03, 2021, 01:08:57 amBart, I have no time to post a Bug report because it seems to go no where in any case. Well, given my replies in this thread, I don't really see how you came to that conclusion. Bart ---------------------------------------------------------------------- wp · 2021-10-03 08:36 Quote from: jamie on October 03, 2021, 01:08:57 amBart, I have no time to post a Bug report because it seems to go no where in any case. Is it this closed one: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/38388? Your patch was applied, and you were asked whether it works, and you confirmed. So, what are you complaining about? ---------------------------------------------------------------------- Bart · 2021-10-03 10:55 Fixed the Modified issue (I think): 2e98d119 T(Float)SpinEditEx: set Modified to False if Value is set programmatically.abd3cd5c T(Float)SpinEdit: set Modified to False if Value is set programmatically. It already worked when you set Text programmatically. Bart ---------------------------------------------------------------------- Bart · 2021-10-03 14:07 I see, however, I'm not sure how to solve that. The problem hrer is that SetValue ultimately calls RealSetText of the Edit (in the case of TSpinEditEx), which then sets Modified to False. Any idea how to solve that? Bart ---------------------------------------------------------------------- Bart · 2021-10-03 14:27 I hope I possibly solved it for SpinEditEx in #e868afe1 #16c42cea . Bart [ETA] Updated revision hash. ---------------------------------------------------------------------- Bart · 2021-10-03 14:49 Quote from: jamie on October 03, 2021, 04:33:14 pmits all based form the customFloatSpinEdit I think its called, shouldn't it be solved for that so that all others will use the same fix ? No, the T(Float)SpinEditEx family has access to the underlying Edit control (it does not inherit from TCustomEdit, it is a compound control) , so it has acces to it's OnChange event. So, you can set Modified there, just before OnChange is called. T(Float)SpinEdit OTH is a native control and setting I tried setting Modified in TextChanged (which will call Chaged, which calls OnChange), but this does not work, somewhere along the line Modified gets reset to True even if I set it to False in TextChanged. Bart ---------------------------------------------------------------------- hennerd · 2021-10-03 17:05 Quote from: Bart on October 02, 2021, 01:20:40 pmQuote from: Neville on October 02, 2021, 11:28:55 amI find that with TSpinEdit, if both MaxValue and MinValue are set to the same number, then the component acts as if no limits were present at all. This is by design, it is Delphi compatible. I can see that this is not properly documented though. Bart Actually the Cocoa implementation of TSpinEdit behaves differently: if MinValue = 0 and MaxValue = 0, Value cannot be changed, it is always 0. ---------------------------------------------------------------------- skalogryz · 2021-10-03 18:07 Quote from: hennerd on October 03, 2021, 07:05:42 pmActually the Cocoa implementation of TSpinEdit behaves differently: if MinValue = 0 and MaxValue = 0, Value cannot be changed, it is always 0. this is fixed here (61c40eb..46d12df) ---------------------------------------------------------------------- Bart · 2021-10-03 19:45 I think I may have fixed it in a slightly different way in #2befd9dd. Please test. Bart ---------------------------------------------------------------------- Bart · 2021-10-04 16:43 Quote from: jamie on October 04, 2021, 12:18:20 amYes, it seems to be working now.. I only tested with TSpinEDit, I didn't to the float version but I assume that should also be working.. The changes are in the parent (TFloatSPinEdit), so yes, that should work. I must admit I did not actually test that, but the theory says it should  Bart