From 40234cd3f4ac1ea44f7a2ff925491aa22c0288f5 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sat, 31 Mar 2012 10:56:44 +0000 Subject: [PATCH] Work around a magic automatic TAB key arriving the pulldown grid editor if the user got into this cell via TAB. Only seen for a TComboBox with style=csDropDown. Fixes issue #2809. --- source/grideditlinks.pas | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/source/grideditlinks.pas b/source/grideditlinks.pas index b94a3b6d..94acfa1f 100644 --- a/source/grideditlinks.pas +++ b/source/grideditlinks.pas @@ -35,6 +35,7 @@ type FOldWindowProc: TWndMethod; // Temporary switched to TempWindowProc to be able to catch Tab key FFullDatatype: TDBDatatype; FModified: Boolean; + FBeginEditTime: Cardinal; procedure TempWindowProc(var Message: TMessage); procedure DoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure DoEndEdit(Sender: TObject); @@ -97,6 +98,7 @@ type TEnumEditorLink = class(TBaseGridEditorLink) private FCombo: TComboBox; + procedure DoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); public ValueList, DisplayList: TStringList; AllowCustomText: Boolean; @@ -305,6 +307,7 @@ end; function TBaseGridEditorLink.BeginEdit: Boolean; begin Result := not FStopping; + FBeginEditTime := GetTickCount; end; function TBaseGridEditorLink.CancelEdit: Boolean; @@ -858,6 +861,15 @@ begin end; +procedure TEnumEditorLink.DoKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); +begin + // Work around a magic automatic TAB key arriving the editor if the user got + // into this cell via TAB. Only seen for a TComboBox with style=csDropDown. + // See issue #2809 + if not (AllowCustomText and (GetTickCount-FBeginEditTime < 200)) then + inherited; +end; + { SET editor }