- This topic has 24 replies, 2 voices, and was last updated 4 years, 1 month ago by HeDiBo.
-
AuthorPosts
-
August 1, 2020 at 10:19 am #69165HeDiBoParticipant
Suppose I have a data field that receives its values from some external proces. It is possible to change the value by hand, but then some max and min restrictions apply.
In AC this is not possible at all!! You have all or nothing.
It’s common practice, I think, to honor such restrictions only on user input. You don’t want to falsify a data value in display, no matter what its max or min values are: these restrictions only apply to input values.August 2, 2020 at 9:56 am #69166HeDiBoParticipantThere 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 🤐August 4, 2020 at 3:14 pm #69178SupportKeymasterIf 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?
August 4, 2020 at 4:04 pm #69179HeDiBoParticipantIf 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 4 years, 3 months ago by HeDiBo.
August 5, 2020 at 11:38 am #69181HeDiBoParticipantThis 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.August 5, 2020 at 12:34 pm #69183HeDiBoParticipantNot 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.August 5, 2020 at 12:47 pm #69184HeDiBoParticipantHow can I internationalize the string ‘The value is out of min/max bounds’?
August 5, 2020 at 1:05 pm #69186HeDiBoParticipantThere 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 😒
August 6, 2020 at 1:26 pm #69198SupportKeymasterHi!
I will think how to make it better, time is needed for that.- This reply was modified 4 years, 3 months ago by Support.
August 6, 2020 at 5:28 pm #69206HeDiBoParticipantMaybe 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.
August 11, 2020 at 8:33 pm #69225SupportKeymasterSome changes will be added in the nearest release.
You will be able to try it at the end of this week.August 28, 2020 at 10:07 am #69365HeDiBoParticipantI 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).
August 28, 2020 at 10:23 am #69366HeDiBoParticipantThe 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 4 years, 2 months ago by HeDiBo.
August 28, 2020 at 11:27 am #69372HeDiBoParticipantIn 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!!
August 29, 2020 at 6:27 pm #69381SupportKeymasterI will check it soon.
August 31, 2020 at 1:25 pm #69390SupportKeymasterAbout 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 4 years, 2 months ago by Support.
September 1, 2020 at 11:35 am #69395HeDiBoParticipantThe 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?
September 1, 2020 at 11:52 am #69396HeDiBoParticipantThis 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!
September 2, 2020 at 9:07 pm #69406SupportKeymasterSorry, I was thinking about the DataLink.Modified, don’t know why.
I will check if TCustomEdit.Modified may be used there.September 7, 2020 at 1:32 pm #69436HeDiBoParticipant<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 happenIt 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 4 years, 2 months ago by HeDiBo.
-
AuthorPosts
- You must be logged in to reply to this topic.