View Issue Details

IDProjectCategoryView StatusLast Update
0000766JEDI VCL00 JVCL Componentspublic2003-05-21 08:18
ReporterrokoAssigned Touser72 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.00 
Target VersionFixed in Version 
Summary0000766: TJvSpinEdit: OnChange event isn't fired
DescriptionWhile testing ChangeOptions behavior, I noticed that OnChange event of TJvSpinEdit isn't fired whatever I do with control in runtime. I pressed keys, pressed up/down arrows - value changed in control, it went out of range, but OnChange event in my form wasn't fired.
The only way I got it to fire was setting coCheckOnExit in ChangeOptions - when I typed value out of range and switched to other control, OnChange fired.
So I examined source, and found culprit.
Additional Informationprocedure TJvCustomSpinEdit.Change;
var
>> OldText: string;
  OldSelStart: Integer;
begin
  { (rb) Maybe move to CMTextChanged }
  if FChanging or not HandleAllocated then
    Exit;

  FChanging := True;
  try
>> OldText := inherited Text;
    OldSelStart := SelStart;
    try
      if not (csDesigning in ComponentState) and (coCheckOnChange in CheckOptions) then
      begin
        CheckValueRange(Value, True);
        SetValue(CheckValue(Value));
      end;
    except
      SetValue(CheckValue(Value));
    end;
  finally
    FChanging := False;
  end;

>> if CompareText(inherited Text, OldText) <> 0 then
    inherited Change;

  SelStart := OldSelStart;
end;

Lines marked with '>>' seem to be redundant, as in my tests inherited Text is always equal OldText. After removing these lines everything seems to work.
TagsNo tags attached.

Relationships

has duplicate 0000838 closeduser199 TJvSpinEdit OnChange() event does not work 
has duplicate 0000896 closedremkobonte OnChange event not firing in TJVSpinEdit 

Activities

boerema1

2003-03-16 12:09

reporter   ~0001815

This is because at the start of the Change method the inherited Text already has the changed value.
What I did was change the Change method in the following way (which is close to the way it was in JVCL 2.0)

Instead of:
  if CompareText(inherited Text, OldText) <> 0 then
    inherited Change;

I now use:
  if Value <> FOldValue then
  begin
    inherited Change;
    FOldValue:= Value;
  end;

(Don't forget to (re)add FOldValue to TJvCustomSpinEdit and setting FOldValue to 0 in Create.

user72

2003-03-17 10:13

  ~0001821

Seems to work fine. Updated in CVS. Thanks

user199

2003-05-21 08:18

  ~0002099

This fix has been working for quite a while. Closed.

Issue History

Date Modified Username Field Change