diff --git a/lcl/controls.pp b/lcl/controls.pp index e3756e1010..30b729a3e9 100644 --- a/lcl/controls.pp +++ b/lcl/controls.pp @@ -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; diff --git a/lcl/include/control.inc b/lcl/include/control.inc index 66e06ffbc1..678c8d8c7a 100644 --- a/lcl/include/control.inc +++ b/lcl/include/control.inc @@ -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); diff --git a/lcl/include/customupdown.inc b/lcl/include/customupdown.inc index 4403a35ba8..6d0deba3fc 100644 --- a/lcl/include/customupdown.inc +++ b/lcl/include/customupdown.inc @@ -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); diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index fe7082bbd7..25f2402a0c 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -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; {------------------------------------------------------------------------------