TsDBCalcEdit should not honor Min and Max on displaying values

Viewing 20 posts - 1 through 20 (of 24 total)
  • Author
    Posts
  • #69166
    HeDiBo
    Participant

      There is another problem with MinValue in this control.
      If you insert a record, the control is prefilled with this minimum value, when the user focuses the control. At least so it seems. However if the user goes to another control, the TsDBCalcEdit control is cleared again. So, in stead of filling the data field with the minimum value, the data field stays cleared. Then when the record is posted, it is posted with an empty data field, which is the worst that can happen 🤐

      #69178
      Support
      Keymaster

        If the new AutoValueCorrect property is False, then developer is able to handle this error in the OnValidateError event. Value will not be autocorrected and developer can leave it as is. Will it help?

        #69179
        HeDiBo
        Participant

          If the new AutoValueCorrect property is False, then developer is able to handle this error in the OnValidateError event. Value will not be auto corrected and developer can leave it as is. Will it help?

          I don’t think so. Values that by reading a dataset are put in a TsDBCalcEdit should appear there unaltered!!
          This is a principle. By not honoring the content of the datafield, the program falsifies data!

          • This reply was modified 5 years, 7 months ago by HeDiBo.
          #69181
          HeDiBo
          Participant

            This picture shows the problem.
            The grid’s current row is duplicated in the area below the navigator.
            However, the value of the highlighted field is falsified!!
            Suppose the values depict a danger level. It should not be possible that such a vital value is totally changed.

            Attachments:
            You must be logged in to view attached files.
            #69183
            HeDiBo
            Participant

              Not checking values for output will also fix this nasty bug:

                procedure DoMinMaxError;
                var
                  s: acString;
                begin
                  s := 'The value is out of min/max bounds';
                  if not (csDesigning in ComponentState) then
                    SetFocus;     <<<<< Throws exception <<<<<
              
                  if Assigned(OnValidateError) then
                    OnValidateError(Self, s)
                  else
                    raise EDBEditError.Create(s);
                end;

              The procdure DoMinMaxError is also called when displaying the value. If the control cannot be focused, an exception occurs.
              Why would you focus a control used for output!! Probably because you only should do this procedure in case of input.

              #69184
              HeDiBo
              Participant

                How can I internationalize the string ‘The value is out of min/max bounds’?

                #69186
                HeDiBo
                Participant

                  There is another problem with MinValue in this control.
                  If you insert a record, the control is prefilled with this minimum value, when the user focuses the control. At least so it seems. However if the user goes to another control, the TsDBCalcEdit control is cleared again. So, in stead of filling the data field with the minimum value, the data field stays cleared. Then when the record is posted, it is posted with an empty data field, which is the worst that can happen 🤐

                  Still a bug in AC 15.13 😒

                  #69198
                  Support
                  Keymaster

                    Hi!
                    I will think how to make it better, time is needed for that.

                    • This reply was modified 5 years, 7 months ago by Support.
                    #69206
                    HeDiBo
                    Participant

                      Maybe you can make SetValue an overridable procedure. Then if the value comes from the program and not from the user input, you skip all checking.

                      #69225
                      Support
                      Keymaster

                        Some changes will be added in the nearest release.
                        You will be able to try it at the end of this week.

                        #69365
                        HeDiBo
                        Participant

                          I analyzed the changes you made and many of them involved setting or testing FTextChangedByUser. Apparently you didn’t know of the public property Modified of TCustomEdit. It does exactly that. It circumvents a lot of coding, I think. And the setters and getters also send you a message (EM_GETMODIFY / EM_SETMODIFY).

                          #69366
                          HeDiBo
                          Participant

                            The OnValidateError event occurs too many times. In particular it occurs in the creation phase of the control. I think the error is in the overridden SetValue procedure. Not every time a value is posted to the TsDBCalcEdit control, that value is entered by the user. The following change makes it work, I think.

                            procedure TsDBCalcEdit.SetValue(AValue: Extended);
                            begin
                              if Modified then FTextChangedByUser := True;   (**** DB ****)
                            { FTextChangedByUser := Modified;  } // *** DB *** This may actually work better
                              inherited SetValue(AValue);
                            end;

                            Again, using the Modified property i.s.o. FTextChangedByUser may do the trick.

                            • This reply was modified 5 years, 6 months ago by HeDiBo.
                            #69372
                            HeDiBo
                            Participant

                              In the OnValidateError event, I cannot get to the value entered. It returns the previous value.

                              Also the string ‘The value is out of min/max bounds’ should be localizable.

                              When a record is inserted, the control is no longer prefilled with the minimum value. It is cleared in stead. And this cleared field is considered an acceptable value!!

                              #69381
                              Support
                              Keymaster

                                I will check it soon.

                                #69390
                                Support
                                Keymaster

                                  About the FTextChangedByUser: I need to divide all changes that processed in the component.
                                  1. If value of the component is changed by the DB engine then I will not check Min/Max values and value is added unaltered, according to your request
                                  2. If value is changed by user then it should be checked (if control is configured for automatic checking).
                                  This is a reason why FTextChangedByUser has been added, because “Modified” don’t let me know how the value has been changed (by user or by dataset).

                                  • This reply was modified 5 years, 6 months ago by Support.
                                  #69395
                                  HeDiBo
                                  Participant

                                    The OnValidateError event is thrown twice.
                                    Once in this:

                                    procedure TsCustomNumEdit.CMExit(var Message: TCMExit);
                                    begin
                                      try
                                        CheckRange;
                                        UpdateData;
                                      except

                                    and immediately after that in here:

                                    procedure TsCustomNumEdit.UpdateData;
                                    var
                                      s: string;
                                      Minus: integer;
                                    begin
                                      s := Text;
                                      if pos(CharMinus, s) = 1 then begin
                                        Delete(s, 1, 1);
                                        Minus := -1
                                      end
                                      else
                                        Minus := 1;
                                    
                                      FValue := CheckValue(StrToFloat(TextToValText(ZeroChar + s)) * Minus);
                                    end;

                                    Maybe the CheckRange in CMExit should go?

                                    #69396
                                    HeDiBo
                                    Participant

                                      This is the text of the Modified property help:

                                      Indicates whether the user edited the text of the edit control.

                                      Use Modified to determine whether the user changed the Text property of the edit control. Modified is only reset to False when you assign a value to the Text property. In particular, it is not reset when the control receives focus.

                                      Important is the first line: it is set when the USER changed the text property. Is your information different? DO you think that reading the control’s value from a database sets Modified too?

                                      I tested that and I cannot produce a Modified set if the dataset record changes. On the contrary: if a record is read causing the text of the control to change, the Modified property is set to False!

                                      #69406
                                      Support
                                      Keymaster

                                        Sorry, I was thinking about the DataLink.Modified, don’t know why.
                                        I will check if TCustomEdit.Modified may be used there.

                                        #69436
                                        HeDiBo
                                        Participant

                                          <p zoompage-fontsize=”14″>There is another problem with MinValue in this control.
                                          If you insert a record, the control is prefilled with this minimum value, when the user focuses the control. At least so it seems. However if the user goes to another control, the TsDBCalcEdit control is cleared again. So, in stead of filling the data field with the minimum value, the data field stays cleared. Then when the record is posted, it is posted with an empty data field, which is the worst that can happen

                                          It is worse now. When a user inserts a record, the control is no longer prefilled with the minimum value, but it is cleared. And furthermore this cleared value is considered valid 😒😯😲

                                          • This reply was modified 5 years, 6 months ago by HeDiBo.
                                          #69468
                                          HeDiBo
                                          Participant

                                            The problem from #69395 is still present in 15.15.
                                            That is such a simple fix, why is it still there ⁉

                                          Viewing 20 posts - 1 through 20 (of 24 total)
                                          • You must be logged in to reply to this topic.