- Posts: 66
- Thank you received: 0
- Forum
- CodeTyphon Studio
- CodeTyphon Studio Components and Libraries
- General Purpose
- TKNumberEdit (and other numeric edits)
×
General Purpose Components and Libraries, discussions, problems and suggestions
Question TKNumberEdit (and other numeric edits)
- Fernando
- Topic Author
- Offline
- Junior Member
-
Less
More
2 years 8 months ago #11781
by Fernando
TKNumberEdit (and other numeric edits) was created by Fernando
Hello,
I was looking for a numeric component capable of entering float numbers, including exponential notation. In delphi, i Had used succesfully orpheus' flexedit, but here it does not work well: in Typhon32, I can put flexedit in a form and use it, but if that form is modal the second time it is shown with ShowModal it looks empty, no controls are painted at all, and it cannot be closed. On Typhon64, dropping flex edit on a form causes de IDE to crash.
Looking for replacements, it was difficult to find a numeric edit which could handle properly exponential notation. The only that I got working in this way is TKNumberEdit, but I found that it accepts exponential numbers like 1.5E5 but not 1.5E-5 nor 1.5E+5. A quick look into the code revealed this, in function TKNumberEdit.InspectInputChar (file kedits.pas), line 1425 and ff:Albeit 'E' and 'e' are accepted, the problem is in line 1430:This only allows a minus sign as the first character, but not after the 'E' or 'e' (neither a '+' sign is allowed, by the way).
I edited the above fragment as here:Now it allows 1.5E5, 1.5E-5 and 1.5E+5 (plus a '+' at the number start), which works well for me.
My question is: is it possible to incorporate this fix into the version of kcontros distributed with CT? I posted this fix in the k controls website (tkweb.eu) but got no answer so far; in fact there seems to be no work ant all on edits in the last years there, so I ask here.
Regards
Fernando
I was looking for a numeric component capable of entering float numbers, including exponential notation. In delphi, i Had used succesfully orpheus' flexedit, but here it does not work well: in Typhon32, I can put flexedit in a form and use it, but if that form is modal the second time it is shown with ShowModal it looks empty, no controls are painted at all, and it cannot be closed. On Typhon64, dropping flex edit on a form causes de IDE to crash.
Looking for replacements, it was difficult to find a numeric edit which could handle properly exponential notation. The only that I got working in this way is TKNumberEdit, but I found that it accepts exponential numbers like 1.5E5 but not 1.5E-5 nor 1.5E+5. A quick look into the code revealed this, in function TKNumberEdit.InspectInputChar (file kedits.pas), line 1425 and ff:
if neafFloat in FAcceptedFormats then
begin
KeyFloat := Key;
if CharInSetEx(KeyFLoat, ['0'..'9','-', '.', ',', 'e', 'E', DecimalSeparator, #8]) then
begin
if (KeyFloat = '-') and (SelStart <> 0) then KeyFloat := #0;
if CharInSetEx(KeyFLoat, ['.', ',', DecimalSeparator]) and
((Pos('.', S) <> 0) or (Pos(',', S) <> 0) or (Pos(DecimalSeparator, S) <> 0)) then
KeyFloat := #0;
end else
KeyFloat := #0;
if (KeyFloat = '-') and (SelStart <> 0) then KeyFloat := #0;
I edited the above fragment as here:
if neafFloat in FAcceptedFormats then
begin
KeyFloat := Key;
if CharInSetEx(KeyFLoat, ['0'..'9','-', '+', '.', ',', 'e', 'E', DecimalSeparator, #8]) then //added '+'
begin
if (KeyFloat = '-') and ((SelStart <> 0) and (UpCase(S[SelStart]) <> 'E')) then KeyFloat := #0; //added: "and (UpCase(S[SelStart]) <> 'E')"
if (KeyFloat = '+') and ((SelStart <> 0) and (UpCase(S[SelStart]) <> 'E')) then KeyFloat := #0; //new line added
if CharInSetEx(KeyFLoat, ['.', ',', DecimalSeparator]) and
((Pos('.', S) <> 0) or (Pos(',', S) <> 0) or (Pos(DecimalSeparator, S) <> 0)) then
KeyFloat := #0;
end else
KeyFloat := #0;
My question is: is it possible to incorporate this fix into the version of kcontros distributed with CT? I posted this fix in the k controls website (tkweb.eu) but got no answer so far; in fact there seems to be no work ant all on edits in the last years there, so I ask here.
Regards
Fernando
Please Log in or Create an account to join the conversation.
- Sternas Stefanos
-
- Offline
- Moderator
-
- Ex Pilot, M.Sc, Ph.D
2 years 8 months ago - 2 years 8 months ago #11782
by Sternas Stefanos
PilotLogic Architect and Core Programmer
Replied by Sternas Stefanos on topic TKNumberEdit (and other numeric edits)
Thanks Sir
we will put your fix to pl_kcontrols for next CT release
we will put your fix to pl_kcontrols for next CT release
PilotLogic Architect and Core Programmer
Last edit: 2 years 8 months ago by Sternas Stefanos.
The following user(s) said Thank You: Fernando
Please Log in or Create an account to join the conversation.
- Sternas Stefanos
-
- Offline
- Moderator
-
- Ex Pilot, M.Sc, Ph.D
2 years 8 months ago #11783
by Sternas Stefanos
PilotLogic Architect and Core Programmer
Replied by Sternas Stefanos on topic TKNumberEdit (and other numeric edits)
Please try and this LAB CT version
pl_KControls Ver 6.6.1 Source GIT hash : 0dbad6b6449e2cc1ac56e57fb15ca3a245f5ebf4
your fix is now at kedits.pas line: 1264
pl_KControls Ver 6.6.1 Source GIT hash : 0dbad6b6449e2cc1ac56e57fb15ca3a245f5ebf4
your fix is now at kedits.pas line: 1264
PilotLogic Architect and Core Programmer
Please Log in or Create an account to join the conversation.
- Fernando
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 66
- Thank you received: 0
2 years 8 months ago - 2 years 8 months ago #11784
by Fernando
Replied by Fernando on topic TKNumberEdit (and other numeric edits)
Hi,
Number input works as expected. But there are two little problems, which seem new:
1. The control has the option neoUseUpDown which causes to display up and down buttons to the right of the control. Setting it to False used to hide the buttons. With this new version, the buttons are always displayed, only are hidden when the user starts typing, if the option is False.
2. In the object inspector there are two new properties, MaxAsInt and MinAsInt (integers) which interact with Max and Min (doubles), trying to keep the same value, which leds to errors if one attempts to set big absolute values in Max and Min (e.g. 1e300 and -1e300). There is a workaround, which is to set the deisred Max and Min dinamically, for example in FormCreate event.
I did not test other controls in the package so far.
Overall, it works, with the nuisance of 1 above.
Number input works as expected. But there are two little problems, which seem new:
1. The control has the option neoUseUpDown which causes to display up and down buttons to the right of the control. Setting it to False used to hide the buttons. With this new version, the buttons are always displayed, only are hidden when the user starts typing, if the option is False.
2. In the object inspector there are two new properties, MaxAsInt and MinAsInt (integers) which interact with Max and Min (doubles), trying to keep the same value, which leds to errors if one attempts to set big absolute values in Max and Min (e.g. 1e300 and -1e300). There is a workaround, which is to set the deisred Max and Min dinamically, for example in FormCreate event.
I did not test other controls in the package so far.
Overall, it works, with the nuisance of 1 above.
Last edit: 2 years 8 months ago by Fernando.
Please Log in or Create an account to join the conversation.
- Sternas Stefanos
-
- Offline
- Moderator
-
- Ex Pilot, M.Sc, Ph.D
2 years 8 months ago #11785
by Sternas Stefanos
PilotLogic Architect and Core Programmer
Replied by Sternas Stefanos on topic TKNumberEdit (and other numeric edits)
Thanks Sir
we will try to fix and this
we will try to fix and this
PilotLogic Architect and Core Programmer
Please Log in or Create an account to join the conversation.
- Fernando
- Topic Author
- Offline
- Junior Member
-
Less
More
- Posts: 66
- Thank you received: 0
2 years 5 months ago #12673
by Fernando
Replied by Fernando on topic TKNumberEdit (and other numeric edits)
Hello Sternas,
Revisiting the item 1 in my post above, I was able to fix it as follows: in the procedure TKCustomNumberEdit.SetOptions (line 1596 and ff of current lab version of kedits.pas) I added a line to change the Visible status of the UpDown part of the control. The corrected procedure is:
With this fix, this control is working well for me.
Regards
Revisiting the item 1 in my post above, I was able to fix it as follows: in the procedure TKCustomNumberEdit.SetOptions (line 1596 and ff of current lab version of kedits.pas) I added a line to change the Visible status of the UpDown part of the control. The corrected procedure is:
procedure TKCustomNumberEdit.SetOptions(AValue: TKNumberEditOptions);
begin
if FOptions <> AValue then
begin
TextToValue;
FOptions := AValue;
UpdateLabel;
UpdateMaxMin;
ValueToText;
FUpDown.Visible:= (neoUseUpDown in AValue); //added to fix bug: UpDown visible after changing option to do not use
end;
end;
With this fix, this control is working well for me.
Regards
Please Log in or Create an account to join the conversation.
- Sternas Stefanos
-
- Offline
- Moderator
-
- Ex Pilot, M.Sc, Ph.D
2 years 5 months ago #12675
by Sternas Stefanos
PilotLogic Architect and Core Programmer
Replied by Sternas Stefanos on topic TKNumberEdit (and other numeric edits)
Thanks Sir
we add your fix to LAB CT
we add your fix to LAB CT
PilotLogic Architect and Core Programmer
The following user(s) said Thank You: Fernando
Please Log in or Create an account to join the conversation.