From e9bfcc0273820375cf62a6f5ad0a517b93b2ea65 Mon Sep 17 00:00:00 2001 From: ondrej Date: Wed, 19 Oct 2016 10:25:58 +0000 Subject: [PATCH] SpinEdit: support setting Text property git-svn-id: trunk@53159 - --- lcl/include/spinedit.inc | 10 ++++++++++ lcl/spin.pp | 1 + 2 files changed, 11 insertions(+) diff --git a/lcl/include/spinedit.inc b/lcl/include/spinedit.inc index 55a7925022..466dcb718b 100644 --- a/lcl/include/spinedit.inc +++ b/lcl/include/spinedit.inc @@ -41,6 +41,16 @@ begin Result := ValueToStr(FValue); end; +procedure TCustomFloatSpinEdit.RealSetText(const AValue: TCaption); +var + NewValue: Double; +begin + if TryStrToFloat(AValue, NewValue) then + Value := NewValue + else + inherited RealSetText(AValue); +end; + procedure TCustomFloatSpinEdit.TextChanged; var PrevValue: Double; diff --git a/lcl/spin.pp b/lcl/spin.pp index 58d84496ae..e099f8e839 100644 --- a/lcl/spin.pp +++ b/lcl/spin.pp @@ -44,6 +44,7 @@ type protected class procedure WSRegisterClass; override; function RealGetText: TCaption; override; + procedure RealSetText(const AValue: TCaption); override; procedure TextChanged; override; procedure SetDecimals(ADecimals: Integer); virtual; procedure SetValue(const AValue: Double); virtual;