diff --git a/components/jujiboutils/changes.txt b/components/jujiboutils/changes.txt index cd7930dcf..8af6d177f 100644 --- a/components/jujiboutils/changes.txt +++ b/components/jujiboutils/changes.txt @@ -5,6 +5,7 @@ Note: Lazarus Trunk required Version pre-1.1 -------------------------------------------------- +2012-03-14 Fixed: Prevent double updates (QT widgetset) in edit widgets 2012-03-06 Fixed: Focus issues Version 1.0 diff --git a/components/jujiboutils/src/jdblabeledcurrencyedit.pas b/components/jujiboutils/src/jdblabeledcurrencyedit.pas index 58782a350..5f9ae7a52 100644 --- a/components/jujiboutils/src/jdblabeledcurrencyedit.pas +++ b/components/jujiboutils/src/jdblabeledcurrencyedit.pas @@ -35,6 +35,7 @@ type fFormat: string; FDataLink: TFieldDataLink; fDecimales: integer; + fUpdated: boolean; procedure DataChange(Sender: TObject); function getDecimals: integer; @@ -174,29 +175,31 @@ procedure TJDBLabeledCurrencyEdit.UpdateData(Sender: TObject); var theValue: currency; begin - if FDataLink.Field <> nil then - begin - if IsValidCurrency(Text) then + if not fUpdated then + if FDataLink.Field <> nil then begin - theValue := StrToCurr(Text); - if fDecimales > 0 then - theValue := ScaleTo(theValue, fDecimales); - Text := CurrToStr(theValue); - FDataLink.Field.Value := theValue; + if IsValidCurrency(Text) then + begin + theValue := StrToCurr(Text); + if fDecimales > 0 then + theValue := ScaleTo(theValue, fDecimales); + Text := CurrToStr(theValue); + FDataLink.Field.Value := theValue; + fUpdated:= True; + end + else + begin + if FDataLink.Field <> nil then + begin + ShowMessage(Format(SInvalidNumber, [Caption])); + Caption := FDataLink.Field.AsString; + SelectAll; + SetFocus; + end; + end; end else - begin - if FDataLink.Field <> nil then - begin - ShowMessage(Format(SInvalidNumber, [Caption])); - Caption := FDataLink.Field.AsString; - SelectAll; - SetFocus; - end; - end; - end - else - Text := ''; + Text := ''; end; procedure TJDBLabeledCurrencyEdit.FocusRequest(Sender: TObject); @@ -356,13 +359,15 @@ procedure TJDBLabeledCurrencyEdit.DoEnter; begin if FDataLink.Field <> nil then Caption := FDataLink.Field.AsString; + fUpdated:= False; inherited DoEnter; end; procedure TJDBLabeledCurrencyEdit.DoExit; begin - formatInput; inherited DoExit; + UpdateData(nil); + formatInput; end; constructor TJDBLabeledCurrencyEdit.Create(TheOwner: TComponent); diff --git a/components/jujiboutils/src/jdblabeledfloatedit.pas b/components/jujiboutils/src/jdblabeledfloatedit.pas index 821577905..daa0346c7 100644 --- a/components/jujiboutils/src/jdblabeledfloatedit.pas +++ b/components/jujiboutils/src/jdblabeledfloatedit.pas @@ -35,6 +35,7 @@ type fFormat: string; FDataLink: TFieldDataLink; fDecimales: integer; + fUpdated: boolean; procedure DataChange(Sender: TObject); function getDecimals: integer; @@ -173,29 +174,31 @@ procedure TJDBLabeledFloatEdit.UpdateData(Sender: TObject); var theValue: double; begin - if FDataLink.Field <> nil then - begin - if IsValidFloat(Text) then + if not fUpdated then + if FDataLink.Field <> nil then begin - theValue := StrToFloat(Text); - if fDecimales > 0 then - theValue := ScaleTo(theValue, fDecimales); - Text := FloatToStr(theValue); - FDataLink.Field.Value := theValue; + if IsValidFloat(Text) then + begin + theValue := StrToFloat(Text); + if fDecimales > 0 then + theValue := ScaleTo(theValue, fDecimales); + Text := FloatToStr(theValue); + FDataLink.Field.Value := theValue; + fUpdated := True; + end + else + begin + if FDataLink.Field <> nil then + begin + ShowMessage(Format(SInvalidNumber, [Caption])); + Caption := FDataLink.Field.AsString; + SelectAll; + SetFocus; + end; + end; end else - begin - if FDataLink.Field <> nil then - begin - ShowMessage(Format(SInvalidNumber, [Caption])); - Caption := FDataLink.Field.AsString; - SelectAll; - SetFocus; - end; - end; - end - else - Text := ''; + Text := ''; end; procedure TJDBLabeledFloatEdit.FocusRequest(Sender: TObject); @@ -354,13 +357,15 @@ procedure TJDBLabeledFloatEdit.DoEnter; begin if FDataLink.Field <> nil then Caption := FDataLink.Field.AsString; + fUpdated := False; inherited DoEnter; end; procedure TJDBLabeledFloatEdit.DoExit; begin - formatInput; inherited DoExit; + UpdateData(nil); + formatInput; end; constructor TJDBLabeledFloatEdit.Create(TheOwner: TComponent); diff --git a/components/jujiboutils/src/jdblabeledintegeredit.pas b/components/jujiboutils/src/jdblabeledintegeredit.pas index 2e7479918..a929c8e0a 100644 --- a/components/jujiboutils/src/jdblabeledintegeredit.pas +++ b/components/jujiboutils/src/jdblabeledintegeredit.pas @@ -34,6 +34,7 @@ type private fFormat: string; FDataLink: TFieldDataLink; + fUpdated: boolean; procedure DataChange(Sender: TObject); procedure UpdateData(Sender: TObject); @@ -154,20 +155,24 @@ end; procedure TJDBLabeledIntegerEdit.UpdateData(Sender: TObject); begin - if FDataLink.Field <> nil then - begin - if IsValidInteger(Caption) then - FDataLink.Field.Text := Text - else + if not fUpdated then + if FDataLink.Field <> nil then begin - ShowMessage(Format(SInvalidNumber, [Caption])); - Caption := FDataLink.Field.AsString; - SelectAll; - SetFocus; - end; - end - else - Text := ''; + if IsValidInteger(Caption) then + begin + FDataLink.Field.Text := Text; + fUpdated:= True + end + else + begin + ShowMessage(Format(SInvalidNumber, [Caption])); + Caption := FDataLink.Field.AsString; + SelectAll; + SetFocus; + end; + end + else + Text := ''; end; procedure TJDBLabeledIntegerEdit.FocusRequest(Sender: TObject); @@ -317,13 +322,15 @@ procedure TJDBLabeledIntegerEdit.DoEnter; begin if FDataLink.Field <> nil then Caption := FDataLink.Field.AsString; + fUpdated:= False; inherited DoEnter; end; procedure TJDBLabeledIntegerEdit.DoExit; begin - formatInput; inherited DoExit; + UpdateData(nil); + formatInput; end; constructor TJDBLabeledIntegerEdit.Create(TheOwner: TComponent);