From 2cb6934575fb3582912b1dde15fcec7a0a16bc94 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 12 Nov 2008 15:32:34 +0000 Subject: [PATCH] Se arregla para que no salten las operaciones de insercion y borrado del grid y si las de nuestro controlador git-svn-id: https://192.168.0.254/svn/Proyectos.Acana_FactuGES2/trunk@326 f4e31baf-9722-1c47-927c-6f952f962d4b --- Source/GUIBase/uViewDetallesBase.dfm | 6 +- Source/GUIBase/uViewDetallesBase.pas | 117 ++++++++++++++++----------- 2 files changed, 75 insertions(+), 48 deletions(-) diff --git a/Source/GUIBase/uViewDetallesBase.dfm b/Source/GUIBase/uViewDetallesBase.dfm index fa93ca3c..fd9951e7 100644 --- a/Source/GUIBase/uViewDetallesBase.dfm +++ b/Source/GUIBase/uViewDetallesBase.dfm @@ -64,7 +64,7 @@ inherited frViewDetallesBase: TfrViewDetallesBase DroppedDownWidth = 145 MaxMRUCount = 0 FontName = 'Tahoma' - ItemIndex = 35 + ItemIndex = 34 Options = [foTrueTypeOnly, foNoOEMFonts, foScalableOnly, foWysiWyg] Sorted = True TabOrder = 2 @@ -153,6 +153,7 @@ inherited frViewDetallesBase: TfrViewDetallesBase Align = alClient TabOrder = 1 object cxGridView: TcxGridDBTableView + OnKeyDown = cxGridViewKeyDown NavigatorButtons.ConfirmDelete = False FilterBox.Visible = fvNever OnEditing = cxGridViewEditing @@ -183,6 +184,9 @@ inherited frViewDetallesBase: TfrViewDetallesBase OptionsCustomize.DataRowSizing = True OptionsData.Appending = True OptionsData.CancelOnExit = False + OptionsData.Deleting = False + OptionsData.DeletingConfirmation = False + OptionsData.Inserting = False OptionsSelection.InvertSelect = False OptionsSelection.MultiSelect = True OptionsSelection.UnselectFocusedRecordOnExit = False diff --git a/Source/GUIBase/uViewDetallesBase.pas b/Source/GUIBase/uViewDetallesBase.pas index 3f2a7c10..e958d39a 100644 --- a/Source/GUIBase/uViewDetallesBase.pas +++ b/Source/GUIBase/uViewDetallesBase.pas @@ -139,6 +139,8 @@ type procedure actAnchoAutomaticoUpdate(Sender: TObject); procedure cxGridViewInitEdit(Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem; AEdit: TcxCustomEdit); + procedure cxGridViewKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); private FController : IControllerDetallesBase; @@ -157,6 +159,7 @@ type function darPosicionCAMPO(const Nombre:String): Integer; function darListaSeleccionados: TIntegerArray; + procedure TratamientoTeclas(Key: Word; Shift: TShiftState; AItem: TcxCustomGridTableItem = nil); protected function HayQueRecalcular(AItem: TcxCustomGridTableItem): Boolean; virtual; function EsTipoEditable(AItem: TcxCustomGridTableItem): Boolean; virtual; @@ -328,6 +331,13 @@ end; procedure TfrViewDetallesBase.CustomViewCreate(Sender: TObject); begin inherited; + + //Debemos tener la certeza de que las operaciones del grid estan deshabilitadas y que + //cuando pulsamos teclas de insercion flecha abajo y demas salta nuestra propia lógia del controlador + cxGridView.OptionsData.Appending := False; + cxGridView.OptionsData.Deleting := False; + cxGridView.OptionsData.Inserting := False; + CurEdit := Nil; FUpdating := False; end; @@ -349,53 +359,7 @@ procedure TfrViewDetallesBase.cxGridViewEditKeyDown( AEdit: TcxCustomEdit; var Key: Word; Shift: TShiftState); begin inherited; - cxGridView.BeginUpdate; - try - Case Key of - VK_DOWN : begin - //En el caso de ser la última fila hacemos un append nosotros no el grid - //ya que se saltaria la lógica del controllerDetallesBase - if cxGridView.Controller.IsFinish then - begin - Key := 0; - if Sender.Controller.EditingController.IsEditing then - Sender.Controller.EditingController.Edit.PostEditValue; - actAnadir.Execute; - end; - - //Baja los conceptos seleccionados - if Shift = [ssAlt] then - begin - Key := 0; - actBajar.Execute; - end; - end; - VK_UP : begin - //Sube los conceptos seleccionados - if Shift = [ssAlt] then - begin - Key := 0; - actSubir.Execute; - end; - end; - - VK_RETURN, VK_RIGHT - : begin - //En el caso de ser la última fila hacemos un append nosotros no el grid - //ya que se saltaria la lógica del controllerDetallesBase - if cxGridView.Controller.IsFinish - and AItem.IsLast then - begin - Key := 0; - if Sender.Controller.EditingController.IsEditing then - Sender.Controller.EditingController.Edit.PostEditValue; - actAnadir.Execute; - end; - end; - end; - finally - cxGridView.EndUpdate; - end; + TratamientoTeclas(Key, Shift, AItem); end; procedure TfrViewDetallesBase.cxGridViewEditValueChanged(Sender: TcxCustomGridTableView; AItem: TcxCustomGridTableItem); @@ -460,6 +424,13 @@ begin end; end; +procedure TfrViewDetallesBase.cxGridViewKeyDown(Sender: TObject; var Key: Word; + Shift: TShiftState); +begin + inherited; + TratamientoTeclas(Key, Shift); +end; + procedure TfrViewDetallesBase.cxGridViewStylesGetContentStyle( Sender: TcxCustomGridTableView; ARecord: TcxCustomGridRecord; AItem: TcxCustomGridTableItem; out AStyle: TcxStyle); @@ -734,6 +705,58 @@ begin cxGridView.Controller.EditingController.Edit.PostEditValue; end; +procedure TfrViewDetallesBase.TratamientoTeclas(Key: Word; Shift: TShiftState; + AItem: TcxCustomGridTableItem); +begin + cxGridView.BeginUpdate; + try + case Key of + VK_DOWN : begin + //En el caso de ser la última fila hacemos un append nosotros no el grid + //ya que se saltaria la lógica del controllerDetallesBase + if cxGridView.Controller.IsFinish then + begin + Key := 0; + if _FocusedView.Controller.EditingController.IsEditing then + _FocusedView.Controller.EditingController.Edit.PostEditValue; + actAnadir.Execute; + end; + + //Baja los conceptos seleccionados + if Shift = [ssAlt] then + begin + Key := 0; + actBajar.Execute; + end; + end; + VK_UP : begin + //Sube los conceptos seleccionados + if Shift = [ssAlt] then + begin + Key := 0; + actSubir.Execute; + end; + end; + + VK_RETURN, VK_RIGHT + : begin + //En el caso de ser la última fila hacemos un append nosotros no el grid + //ya que se saltaria la lógica del controllerDetallesBase + if Assigned(AItem) and + cxGridView.Controller.IsFinish and AItem.IsLast then + begin + Key := 0; + if _FocusedView.Controller.EditingController.IsEditing then + _FocusedView.Controller.EditingController.Edit.PostEditValue; + actAnadir.Execute; + end; + end; + end; + finally + cxGridView.EndUpdate; + end; +end; + procedure TfrViewDetallesBase.actAnadirUpdate(Sender: TObject); begin inherited;