I am creating an Delphi 2007 application, using Tnt components (Compenents with unicode). I have a form with:
edit : TTntEdit;
updown : TTntUpDown
settings for thouse components are:
edit.OnKeyPressed := edKeyPress;
edit.OnKExit := edExit;
updown.Max := 900;
updown.Min := 300;
updown.Assosiate := edit;
updown.onClick := updownClick;
procedure TForm.edKeyPress(Sender: TObject;
var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
SetValue(edit, updown, some_global_variable );
end;
end;
procedure TForm.edExit(Sender: TObject);
begin
SetValue(edit, updown, some_global_variable);
end;
procedure TForm.SetValue(ED: tTntEdit;UD: tUpDown;var CardValue: real);
var
rVal : real;
begin
if MainForm.CheckRealStr(ED.Text,rVal,'.') or
MainForm.CheckRealStr(ED.Text,rVal,',') then
begin
if rVal <= (UD.Min/10) then rVal := (UD.Min/10);
if rVal >= (UD.Max/10) then rVal := (UD.Max/10);
CardValue := rVal;
UD.Position := Round(CardValue*10);
ED.Text := FormatFloat('0.0', UD.Position/10 );
end
else
ED.Text := FormatFloat('0.0', UD.Position/10 );
end;
procedure TForm.updownClick(Sender: TObject;
Button: TUDBtnType);
begin
edit.Text := FormatFloat('0.0', updown.Position/10 );
end;
As you can see, UpDown might have position between 300 and 900, thats mean that edit.Text is from '30.0' to '90,0'. If Text is set to 89.8 and we use up arrow of updown to increase it's position, then text in edit will change as follows: '89.9'->'90.0'->'900' and stopes. When edit.text is changing from '90.0' to '900', updownClick event is not even called!
So here is my questions:
- why value '900' appears;
- why updownClick event is not called;