From e36050c80c4c698fdff3b5f4d841e5627f15db2f Mon Sep 17 00:00:00 2001 From: alexs75 Date: Thu, 17 Jul 2014 06:28:07 +0000 Subject: [PATCH] RxDateEdit - fix change date when press +/- key git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3327 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/rx/trunk/tooledit.pas | 55 ++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/components/rx/trunk/tooledit.pas b/components/rx/trunk/tooledit.pas index 53c564104..d5a68d70d 100644 --- a/components/rx/trunk/tooledit.pas +++ b/components/rx/trunk/tooledit.pas @@ -113,6 +113,9 @@ type {$ENDIF} procedure KeyDown(var Key: Word; Shift: TShiftState); override; procedure KeyPress(var Key: Char); override; + + procedure EditKeyDown(var Key: word; Shift: TShiftState); override; + procedure EditKeyPress( var Key: char); override; {$IFDEF OLD_EDITBUTTON} procedure DoButtonClick (Sender: TObject); override; {$ELSE} @@ -782,6 +785,58 @@ begin inherited KeyPress(Key); end; +procedure TCustomRxDateEdit.EditKeyDown(var Key: word; Shift: TShiftState); +begin + if (Key in [VK_PRIOR, VK_NEXT, VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN, + VK_ADD, VK_SUBTRACT]) and + PopupVisible then + begin + TPopupCalendarAccess(FPopup).KeyDown(Key, Shift); + Key := 0; + end + else + if (Shift = []) and DirectInput then + begin + case Key of + VK_ADD: + begin + ApplyDate(NvlDate(Date, Now) + 1); + Key := 0; + end; + VK_SUBTRACT: + begin + ApplyDate(NvlDate(Date, Now) - 1); + Key := 0; + end; + end; + end; + inherited EditKeyDown(Key, Shift); +end; + +procedure TCustomRxDateEdit.EditKeyPress(var Key: char); +begin + if (Key in ['T', 't', '+', '-']) and PopupVisible then + begin + Key := #0; + end + else + if DirectInput then + begin + case Key of + 'T', 't': + begin + ApplyDate(Trunc(Now)); + Key := #0; + end; + '+', '-': + begin + Key := #0; + end; + end; + end; + inherited EditKeyPress(Key); +end; + {$IFDEF OLD_EDITBUTTON} procedure TCustomRxDateEdit.DoButtonClick(Sender: TObject); {$ELSE}