LCL: Make TUpDown.ArrowKeys work. Issue #28537, patch from Denis Kozlov.

git-svn-id: trunk@49726 -
This commit is contained in:
juha 2015-08-29 11:59:12 +00:00
parent 83d51bb80f
commit fdde7f3583
4 changed files with 25 additions and 6 deletions

View File

@ -1370,6 +1370,8 @@ type
procedure RemoveHandler(HandlerType: TControlHandlerType;
const AMethod: TMethod);
procedure DoCallNotifyHandler(HandlerType: TControlHandlerType);
procedure DoCallKeyEventHandler(HandlerType: TControlHandlerType;
var Key: Word; Shift: TShiftState);
procedure DoContextPopup(MousePos: TPoint; var Handled: Boolean); virtual;
procedure SetZOrder(TopMost: Boolean); virtual;
class function GetControlClassDefaultSize: TSize; virtual;

View File

@ -1843,6 +1843,16 @@ begin
FControlHandlers[HandlerType].CallNotifyEvents(Self);
end;
procedure TControl.DoCallKeyEventHandler(HandlerType: TControlHandlerType;
var Key: Word; Shift: TShiftState);
var
i: Integer;
begin
i := FControlHandlers[HandlerType].Count;
while FControlHandlers[HandlerType].NextDownIndex(i) do
TKeyEvent(FControlHandlers[HandlerType][i])(Self, Key, Shift);
end;
{------------------------------------------------------------------------------
procedure TControl.DoContextPopup(const MousePos: TPoint;
var Handled: Boolean);

View File

@ -355,25 +355,31 @@ end;
procedure TCustomUpDown.AssociateKeyDown(Sender: TObject; var Key: Word;
ShiftState : TShiftState);
var
ConsumeKey: Boolean;
begin
If ArrowKeys and (ShiftState = []) then begin
ConsumeKey := False;
if ArrowKeys and (ShiftState = []) then
begin
case FOrientation of
udVertical:
case Key of
VK_Up:
TCustomSpeedButton(FMaxBtn).Click;
begin TCustomSpeedButton(FMaxBtn).Click; ConsumeKey := True; end;
VK_Down:
TCustomSpeedButton(FMinBtn).Click;
begin TCustomSpeedButton(FMinBtn).Click; ConsumeKey := True; end;
end;
udHorizontal:
case Key of
VK_Left:
TCustomSpeedButton(FMinBtn).Click;
begin TCustomSpeedButton(FMinBtn).Click; ConsumeKey := True; end;
VK_Right:
TCustomSpeedButton(FMaxBtn).Click;
begin TCustomSpeedButton(FMaxBtn).Click; ConsumeKey := True; end;
end;
end;
end
end;
if ConsumeKey then
Key := 0;
end;
procedure TCustomUpDown.OnAssociateChangeBounds(Sender: TObject);

View File

@ -5631,6 +5631,7 @@ end;
procedure TWinControl.KeyDown(var Key: Word; Shift: TShiftState);
begin
if Assigned(FOnKeyDown) then FOnKeyDown(Self, Key, Shift);
DoCallKeyEventHandler(chtOnKeyDown, Key, Shift);
end;
{------------------------------------------------------------------------------