TUpDown: implement property MinRepeatInterval.

git-svn-id: trunk@51300 -
This commit is contained in:
bart 2016-01-15 14:17:48 +00:00
parent 8faa0fe7f0
commit a6eb71dd7f
2 changed files with 21 additions and 2 deletions

View File

@ -1825,6 +1825,7 @@ type
{ TCustomUpDown } { TCustomUpDown }
TCustomUpDown = class(TCustomControl) TCustomUpDown = class(TCustomControl)
private private
FAlignButton: TUDAlignButton; FAlignButton: TUDAlignButton;
@ -1837,6 +1838,7 @@ type
FMaxBtn: TControl; // TSpeedButton (TUpDownButton) FMaxBtn: TControl; // TSpeedButton (TUpDownButton)
FMin: SmallInt; FMin: SmallInt;
FMinBtn: TControl; // TSpeedButton (TUpDownButton) FMinBtn: TControl; // TSpeedButton (TUpDownButton)
FMinRepeatInterval: Byte; //Interval starts at 300 and this must be smaller always
FMouseDownBounds : TRect; FMouseDownBounds : TRect;
FMouseTimerEvent: TProcedureOfObject; // the Min/MaxBtn's Click method FMouseTimerEvent: TProcedureOfObject; // the Min/MaxBtn's Click method
FOnChanging: TUDChangingEvent; FOnChanging: TUDChangingEvent;
@ -1854,6 +1856,7 @@ type
procedure SetIncrement(Value: Integer); procedure SetIncrement(Value: Integer);
procedure SetMax(Value: SmallInt); procedure SetMax(Value: SmallInt);
procedure SetMin(Value: SmallInt); procedure SetMin(Value: SmallInt);
procedure SetMinRepeatInterval(AValue: Byte);
procedure SetOrientation(Value: TUDOrientation); procedure SetOrientation(Value: TUDOrientation);
procedure SetPosition(Value: SmallInt); procedure SetPosition(Value: SmallInt);
procedure SetThousands(Value: Boolean); procedure SetThousands(Value: Boolean);
@ -1882,6 +1885,7 @@ type
property Increment: Integer read FIncrement write SetIncrement default 1; property Increment: Integer read FIncrement write SetIncrement default 1;
property Max: SmallInt read FMax write SetMax default 100; property Max: SmallInt read FMax write SetMax default 100;
property Min: SmallInt read FMin write SetMin; property Min: SmallInt read FMin write SetMin;
property MinRepeatInterval: Byte read FMinRepeatInterval write SetMinRepeatInterval default 100;
property OnChanging: TUDChangingEvent read FOnChanging write FOnChanging; property OnChanging: TUDChangingEvent read FOnChanging write FOnChanging;
property OnChangingEx: TUDChangingEventEx read FOnChangingEx write FOnChangingEx; property OnChangingEx: TUDChangingEventEx read FOnChangingEx write FOnChangingEx;
property OnClick: TUDClickEvent read FOnClick write FOnClick; property OnClick: TUDClickEvent read FOnClick write FOnClick;
@ -1910,6 +1914,7 @@ type
property Increment; property Increment;
property Max; property Max;
property Min; property Min;
property MinRepeatInterval;
property OnChanging; property OnChanging;
property OnChangingEx; property OnChangingEx;
property OnClick; property OnClick;

View File

@ -215,6 +215,7 @@ begin
SetInitialBounds(0, 0, CX, CY); SetInitialBounds(0, 0, CX, CY);
FArrowKeys := True; FArrowKeys := True;
FMax := 100; FMax := 100;
FMinRepeatInterval := 100;
FIncrement := 1; FIncrement := 1;
FAlignButton := udRight; FAlignButton := udRight;
FThousands := True; FThousands := True;
@ -227,11 +228,17 @@ begin
end; end;
procedure TCustomUpDown.BTimerExec(Sender : TObject); procedure TCustomUpDown.BTimerExec(Sender : TObject);
var
AInterval:Integer;
begin begin
If Assigned(FMouseTimerEvent) If Assigned(FMouseTimerEvent)
and PtInRect(FMouseDownBounds,Mouse.CursorPos) then begin and PtInRect(FMouseDownBounds,Mouse.CursorPos) then begin
if TTimer(Sender).Interval > 100 AInterval := TTimer(Sender).Interval;
then TTimer(Sender).Interval := TTimer(Sender).Interval - 25; if AInterval > FMinRepeatInterval then begin
AInterval := AInterval - 25;
if AInterval < FMinRepeatInterval then AInterval := FMinRepeatInterval;
TTimer(Sender).Interval := AInterval;
end;
FMouseTimerEvent; FMouseTimerEvent;
end; end;
end; end;
@ -485,6 +492,13 @@ begin
end; end;
end; end;
procedure TCustomUpDown.SetMinRepeatInterval(AValue: Byte);
begin
if FMinRepeatInterval = AValue then Exit;
FMinRepeatInterval := AValue;
if FMinRepeatInterval < 25 then FMinRepeatInterval := 25;
end;
procedure TCustomUpDown.SetMax(Value: SmallInt); procedure TCustomUpDown.SetMax(Value: SmallInt);
begin begin
if Value <> FMax then if Value <> FMax then