From 49e82e3e667a2420c1d991aaced4be0bcda96a41 Mon Sep 17 00:00:00 2001 From: alexs75 Date: Thu, 20 Sep 2012 14:02:20 +0000 Subject: [PATCH] RxDBGrid - fix work lockupcombo cell editor git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2526 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/rx/Demos/RxDBGrid/RxDBGridDemo.lpi | 250 +++++++++--------- .../rx/Demos/RxDBGrid/rxdbgridmainunit.lfm | 2 +- components/rx/rxdbgrid.pas | 42 ++- components/rx/rxpopupunit.pas | 2 + 4 files changed, 174 insertions(+), 122 deletions(-) diff --git a/components/rx/Demos/RxDBGrid/RxDBGridDemo.lpi b/components/rx/Demos/RxDBGrid/RxDBGridDemo.lpi index 91bd94641..a1df8c35d 100644 --- a/components/rx/Demos/RxDBGrid/RxDBGridDemo.lpi +++ b/components/rx/Demos/RxDBGrid/RxDBGridDemo.lpi @@ -54,7 +54,7 @@ - + @@ -62,7 +62,7 @@ - + @@ -75,7 +75,7 @@ - + @@ -84,27 +84,27 @@ - + - + - + - + @@ -115,73 +115,73 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -191,75 +191,75 @@ - + - + - + - + - + - + - + - + - + - + - + @@ -268,41 +268,41 @@ - + - + - + - + - + - + @@ -312,21 +312,21 @@ - + - + - + @@ -336,7 +336,7 @@ - + @@ -346,49 +346,49 @@ - + - + - + - + - + - + - + @@ -398,7 +398,7 @@ - + @@ -406,7 +406,7 @@ - + @@ -414,7 +414,7 @@ - + @@ -422,14 +422,14 @@ - + - + @@ -437,7 +437,7 @@ - + @@ -445,14 +445,14 @@ - + - + @@ -460,14 +460,14 @@ - + - + @@ -476,14 +476,14 @@ - + - + @@ -491,7 +491,7 @@ - + @@ -499,9 +499,9 @@ - - - + + + @@ -512,10 +512,12 @@ + - - - + + + + @@ -523,14 +525,14 @@ - + - + @@ -538,7 +540,7 @@ - + @@ -546,7 +548,7 @@ - + @@ -554,14 +556,14 @@ - + - + @@ -569,21 +571,21 @@ - + - + - + @@ -594,7 +596,7 @@ - + @@ -605,21 +607,21 @@ - + - + - + @@ -627,149 +629,159 @@ - + - + - - - + + + - + - + + + + + + + + + + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - + - + - + - + - - + + - + - + - + - + - + diff --git a/components/rx/Demos/RxDBGrid/rxdbgridmainunit.lfm b/components/rx/Demos/RxDBGrid/rxdbgridmainunit.lfm index 57d23a382..0cd8d0353 100644 --- a/components/rx/Demos/RxDBGrid/rxdbgridmainunit.lfm +++ b/components/rx/Demos/RxDBGrid/rxdbgridmainunit.lfm @@ -257,7 +257,7 @@ object RxDBGridMainForm: TRxDBGridMainForm SelectedColor = clHighlight GridLineStyle = psSolid DataSource = Datasource1 - Options = [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColumnMove, dgColLines, dgRowLines, dgTabs, dgAlwaysShowSelection, dgConfirmDelete, dgCancelOnExit, dgMultiselect, dgHeaderPushedLook] + Options = [dgEditing, dgTitles, dgIndicator, dgColumnResize, dgColumnMove, dgColLines, dgRowLines, dgTabs, dgAlwaysShowSelection, dgConfirmDelete, dgMultiselect, dgHeaderPushedLook] ParentColor = False PopupMenu = PopupMenu1 Scrollbars = ssVertical diff --git a/components/rx/rxdbgrid.pas b/components/rx/rxdbgrid.pas index 8a93f0443..4741c2560 100644 --- a/components/rx/rxdbgrid.pas +++ b/components/rx/rxdbgrid.pas @@ -787,8 +787,9 @@ type procedure KeyDown(var Key: word; Shift: TShiftState); override; procedure msg_SetGrid(var Msg: TGridMessage); message GM_SETGRID; procedure msg_SetValue(var Msg: TGridMessage); message GM_SETVALUE; - procedure ShowList; override; + procedure msg_GetValue(var Msg: TGridMessage); message GM_GETVALUE; procedure OnInternalClosePopup(AResult:boolean);override; + procedure ShowList; override; public constructor Create(AOwner: TComponent); override; destructor Destroy; override; @@ -1191,6 +1192,7 @@ procedure TRxDBGridLookupComboEditor.KeyDown(var Key: word; Shift: TShiftState); procedure doGridKeyDown; begin if Assigned(FGrid) then +// FGrid.EditorkeyDown(Self, key, shift); FGrid.KeyDown(Key, shift); end; @@ -1207,14 +1209,21 @@ procedure TRxDBGridLookupComboEditor.KeyDown(var Key: word; Shift: TShiftState); else Result := False; end; + procedure CheckEditingKey; + begin + if (FGrid=nil) or FGrid.EditorIsReadOnly then + Key := 0; + end; begin + CheckEditingKey; case Key of VK_UP, VK_DOWN: if (not PopupVisible) and (not (ssAlt in Shift)) then begin doGridKeyDown; + Key:=0; exit; end; VK_LEFT, VK_RIGHT: @@ -1231,6 +1240,8 @@ begin end; end; inherited KeyDown(Key, Shift); +{ if FGrid<>nil then + FGrid.EditingDone;} end; procedure TRxDBGridLookupComboEditor.msg_SetGrid(var Msg: TGridMessage); @@ -1258,6 +1269,22 @@ begin end; end; +procedure TRxDBGridLookupComboEditor.msg_GetValue(var Msg: TGridMessage); +var + sText: string; + F:TField; +begin + if Assigned(FGrid.SelectedField) and Assigned(FLDS.DataSet) then + begin + F:=FLDS.DataSet.FieldByName(LookupDisplay); + if Assigned(F) then + begin + sText := F.DisplayText; + Msg.Value := sText; + end; + end; +end; + procedure TRxDBGridLookupComboEditor.ShowList; begin FGrid.GetOnDisplayLookup; @@ -1265,15 +1292,26 @@ begin end; procedure TRxDBGridLookupComboEditor.OnInternalClosePopup(AResult: boolean); + procedure CheckEditingKey; + begin + if (FGrid=nil) or FGrid.EditorIsReadOnly then +// Key := 0; + end; var F:TField; begin inherited OnInternalClosePopup(AResult); + CheckEditingKey; if (AResult) and Assigned(FGrid.SelectedField) and Assigned(FLDS.DataSet) then begin F:=FLDS.DataSet.FieldByName(LookupDisplay); if Assigned(F) then - FGrid.SelectedField.Assign(F); + begin + //FGrid.SelectedField.Assign(F); + if (FGrid<>nil) and Visible then begin + FGrid.SetEditText(FCol, FRow, F.DisplayText); + end; + end; end; end; diff --git a/components/rx/rxpopupunit.pas b/components/rx/rxpopupunit.pas index f9f06eb85..999203c2b 100644 --- a/components/rx/rxpopupunit.pas +++ b/components/rx/rxpopupunit.pas @@ -326,6 +326,8 @@ begin case Key of VK_ESCAPE:Deactivate; VK_RETURN:begin + Key:=0; + Shift:=[]; CloseOk; exit;{In that case we need to exit away.} end;