mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-07 20:58:18 +02:00
T(Float)SpinEdit: make Modified have the correct value in OnChange as well.
This commit is contained in:
parent
16c42ceaa0
commit
2befd9dd7f
@ -32,6 +32,17 @@ begin
|
|||||||
RegisterCustomFloatSpinEdit;
|
RegisterCustomFloatSpinEdit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomFloatSpinEdit.Change;
|
||||||
|
begin
|
||||||
|
//This needs to be done here, not in TextChanged, since the WS causes a Change, but not a TextChanged.
|
||||||
|
if FForceModifiedIsFalseInOnChange then
|
||||||
|
begin
|
||||||
|
Modified := False;
|
||||||
|
FForceModifiedIsFalseInOnChange := False;
|
||||||
|
end;
|
||||||
|
inherited Change;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomFloatSpinEdit.RealGetText: TCaption;
|
function TCustomFloatSpinEdit.RealGetText: TCaption;
|
||||||
begin
|
begin
|
||||||
if HandleAllocated then
|
if HandleAllocated then
|
||||||
@ -140,9 +151,12 @@ begin
|
|||||||
// clear FValueChanged to prevent getting the old value from the widget
|
// clear FValueChanged to prevent getting the old value from the widget
|
||||||
FValueChanged := False;
|
FValueChanged := False;
|
||||||
FUpdatePending := True;
|
FUpdatePending := True;
|
||||||
UpdateControl;
|
|
||||||
|
|
||||||
Modified := False;
|
//UpdateControl will trigger an OnChange through the WS code
|
||||||
|
//Modified will no be reset to True by the WS code, but in this case we need it to be False
|
||||||
|
if not (csLoading in ComponentState) then
|
||||||
|
FForceModifiedIsFalseInOnChange := True;
|
||||||
|
UpdateControl;
|
||||||
|
|
||||||
if not HandleAllocated
|
if not HandleAllocated
|
||||||
and ([csLoading, csDestroying] * ComponentState = [])
|
and ([csLoading, csDestroying] * ComponentState = [])
|
||||||
@ -187,7 +201,8 @@ constructor TCustomFloatSpinEdit.Create(TheOwner: TComponent);
|
|||||||
begin
|
begin
|
||||||
inherited Create(TheOwner);
|
inherited Create(TheOwner);
|
||||||
FCompStyle := csSpinEdit;
|
FCompStyle := csSpinEdit;
|
||||||
|
|
||||||
|
FForceModifiedIsFalseInOnChange := False;
|
||||||
FIncrement := DefIncrement;
|
FIncrement := DefIncrement;
|
||||||
FDecimals := DefDecimals;
|
FDecimals := DefDecimals;
|
||||||
FMaxValue := DefMaxValue;
|
FMaxValue := DefMaxValue;
|
||||||
|
@ -40,6 +40,7 @@ type
|
|||||||
FEditorEnabled: Boolean;
|
FEditorEnabled: Boolean;
|
||||||
FMaxValue: Double;
|
FMaxValue: Double;
|
||||||
FMinValue: Double;
|
FMinValue: Double;
|
||||||
|
FForceModifiedIsFalseInOnChange: Boolean;
|
||||||
FValue: Double;
|
FValue: Double;
|
||||||
FValueEmpty: Boolean;
|
FValueEmpty: Boolean;
|
||||||
FUpdatePending: Boolean;
|
FUpdatePending: Boolean;
|
||||||
@ -51,6 +52,7 @@ type
|
|||||||
function IncrementStored: Boolean;
|
function IncrementStored: Boolean;
|
||||||
protected
|
protected
|
||||||
class procedure WSRegisterClass; override;
|
class procedure WSRegisterClass; override;
|
||||||
|
procedure Change; override;
|
||||||
function RealGetText: TCaption; override;
|
function RealGetText: TCaption; override;
|
||||||
procedure RealSetText(const AValue: TCaption); override;
|
procedure RealSetText(const AValue: TCaption); override;
|
||||||
procedure TextChanged; override;
|
procedure TextChanged; override;
|
||||||
|
Loading…
Reference in New Issue
Block a user