LCL, grids: do AutoEdit on MouseUp it fix double click problem issue #29877

git-svn-id: trunk@52238 -
This commit is contained in:
jesus 2016-04-23 05:32:29 +00:00
parent 1ed4646b29
commit 23712d9f1c

View File

@ -150,7 +150,8 @@ type
TGridFlagsOption = (gfEditorUpdateLock, gfNeedsSelectActive, gfEditorTab, TGridFlagsOption = (gfEditorUpdateLock, gfNeedsSelectActive, gfEditorTab,
gfRevEditorTab, gfVisualChange, gfDefRowHeightChanged, gfColumnsLocked, gfRevEditorTab, gfVisualChange, gfDefRowHeightChanged, gfColumnsLocked,
gfEditingDone, gfSizingStarted, gfPainting, gfUpdatingSize, gfClientRectChange); gfEditingDone, gfSizingStarted, gfPainting, gfUpdatingSize, gfClientRectChange,
gfAutoEditPending);
TGridFlags = set of TGridFlagsOption; TGridFlags = set of TGridFlagsOption;
TSortOrder = (soAscending, soDescending); TSortOrder = (soAscending, soDescending);
@ -6116,14 +6117,12 @@ end;
procedure TCustomGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X, procedure TCustomGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
Y: Integer); Y: Integer);
function DoAutoEdit: boolean; function CheckAutoEdit: boolean;
begin begin
result := FAutoEdit and not(csNoFocus in ControlStyle) and EditingAllowed(FCol) and result := FAutoEdit and not(csNoFocus in ControlStyle) and
(FGCache.ClickCell.X=Col) and (FGCache.ClickCell.Y=Row); EditingAllowed(FCol) and (FGCache.ClickCell.X=Col) and (FGCache.ClickCell.Y=Row);
if result then begin if result then
SelectEditor; GridFlags := GridFlags + [gfAutoEditPending];
EditorShow(True);
end;
end; end;
begin begin
@ -6241,20 +6240,14 @@ begin
CancelSelection; CancelSelection;
if not SelectActive then begin if not SelectActive then begin
CheckAutoEdit;
if not DoAutoEdit then GridFlags := GridFlags + [gfNeedsSelectActive];
// delay select active until mouse reachs another cell
// do that only if editor is not shown
GridFlags := GridFlags + [gfNeedsSelectActive]
else
exit;
FPivot:=FGCache.ClickCell; FPivot:=FGCache.ClickCell;
end; end;
end; end;
end else if DoAutoEdit then begin end else if CheckAutoEDit then begin
{$ifDef dbgGrid} DebugLnExit('MouseDown (autoedit) EXIT'); {$Endif} {$ifDef dbgGrid} DebugLnExit('MouseDown (autoedit) EXIT'); {$Endif}
Exit; Exit;
end; end;
@ -6270,6 +6263,7 @@ begin
end; end;
finally finally
exclude(fGridFlags, gfEditingDone); exclude(fGridFlags, gfEditingDone);
fGridState:=gsSelecting;
end; end;
end; end;
@ -6346,6 +6340,15 @@ var
result := (Cur.X=FGCache.ClickCell.X) and (Cur.Y=FGCache.ClickCell.Y) and (gz<>gzInvalid); result := (Cur.X=FGCache.ClickCell.X) and (Cur.Y=FGCache.ClickCell.Y) and (gz<>gzInvalid);
end; end;
procedure DoAutoEdit;
begin
if (gfAutoEditPending in GridFlags) and not (ssDouble in Shift) then begin
DebugLn('ClickCell:[%d,%d] UpCell:[%d,%d]',[FGCache.ClickCell.x,FGCache.ClickCell.y, Cur.x, Cur.y]);
SelectEditor;
EditorShow(True);
end;
end;
begin begin
inherited MouseUp(Button, Shift, X, Y); inherited MouseUp(Button, Shift, X, Y);
{$IfDef dbgGrid}DebugLn('MouseUP INIT');{$Endif} {$IfDef dbgGrid}DebugLn('MouseUP INIT');{$Endif}
@ -6365,15 +6368,19 @@ begin
end; end;
gsNormal: gsNormal:
if not FixedGrid and IsValidCellClick then if not FixedGrid and IsValidCellClick then begin
doAutoEdit;
CellClick(cur.x, cur.y, Button); CellClick(cur.x, cur.y, Button);
end;
gsSelecting: gsSelecting:
begin begin
if SelectActive then if SelectActive then
MoveExtend(False, Cur.x, Cur.y) MoveExtend(False, Cur.x, Cur.y)
else else begin
doAutoEdit;
CellClick(cur.x, cur.y, Button); CellClick(cur.x, cur.y, Button);
end;
end; end;
gsColMoving: gsColMoving:
@ -6431,7 +6438,7 @@ begin
end; end;
GridFlags := GridFlags - [gfNeedsSelectActive, gfSizingStarted]; GridFlags := GridFlags - [gfNeedsSelectActive, gfSizingStarted, gfAutoEditPending];
if IsPushCellActive() then begin if IsPushCellActive() then begin
ResetPushedCell; ResetPushedCell;