You've already forked lazarus-ccr
Fix: detect properly delete keys. Inerited update only when using standard cell editor
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@2055 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@@ -242,10 +242,6 @@ function IsValidDateString(const Value: string): boolean;
|
|||||||
var
|
var
|
||||||
bTime: TDateTime;
|
bTime: TDateTime;
|
||||||
begin
|
begin
|
||||||
//if StrToDateDef(Value, MaxDateTime) = MaxDateTime then
|
|
||||||
// Result := False
|
|
||||||
//else
|
|
||||||
// Result := True;
|
|
||||||
Result:= TryStrToDate(Value, bTime);
|
Result:= TryStrToDate(Value, bTime);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@@ -186,7 +186,7 @@ end;
|
|||||||
|
|
||||||
procedure TJDBGridControl.UpdateData;
|
procedure TJDBGridControl.UpdateData;
|
||||||
begin
|
begin
|
||||||
if Editor is TJStringCellEditor then
|
if not(Editor is TJStringCellEditor) then
|
||||||
inherited UpdateData;
|
inherited UpdateData;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@@ -341,6 +341,19 @@ end;
|
|||||||
procedure TJDbGridDateTimeCtrl.OnKeyDown(Sender: TObject; var Key: word;
|
procedure TJDbGridDateTimeCtrl.OnKeyDown(Sender: TObject; var Key: word;
|
||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
|
if Key in [VK_DELETE, VK_BACK] then
|
||||||
|
edited := True;
|
||||||
|
if Length(CellEditor.Caption) = 0 then
|
||||||
|
begin
|
||||||
|
if edited then
|
||||||
|
begin
|
||||||
|
Field.DataSet.Edit;
|
||||||
|
Field.Value := Null;
|
||||||
|
theValue := 0;
|
||||||
|
updated := True;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
if Length(CellEditor.Caption) <> 0 then
|
if Length(CellEditor.Caption) <> 0 then
|
||||||
if (Key in [VK_RETURN, VK_TAB, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT]) and
|
if (Key in [VK_RETURN, VK_TAB, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT]) and
|
||||||
(not IsValidDateTimeString(NormalizeDateTime(CellEditor.Caption, theValue))) then
|
(not IsValidDateTimeString(NormalizeDateTime(CellEditor.Caption, theValue))) then
|
||||||
@@ -488,12 +501,17 @@ end;
|
|||||||
procedure TJDbGridTimeCtrl.OnKeyDown(Sender: TObject; var Key: word;
|
procedure TJDbGridTimeCtrl.OnKeyDown(Sender: TObject; var Key: word;
|
||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
|
if Key in [VK_DELETE, VK_BACK] then
|
||||||
|
edited := True;
|
||||||
if Length(CellEditor.Caption) = 0 then
|
if Length(CellEditor.Caption) = 0 then
|
||||||
begin
|
begin
|
||||||
Field.DataSet.Edit;
|
if edited then
|
||||||
Field.Value := Null;
|
begin
|
||||||
theValue := 0;
|
Field.DataSet.Edit;
|
||||||
updated := True;
|
Field.Value := Null;
|
||||||
|
theValue := 0;
|
||||||
|
updated := True;
|
||||||
|
end;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if (Key in [VK_RETURN, VK_TAB, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT]) and
|
if (Key in [VK_RETURN, VK_TAB, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT]) and
|
||||||
@@ -643,6 +661,19 @@ end;
|
|||||||
procedure TJDbGridDateCtrl.OnKeyDown(Sender: TObject; var Key: word;
|
procedure TJDbGridDateCtrl.OnKeyDown(Sender: TObject; var Key: word;
|
||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
|
if Key in [VK_DELETE, VK_BACK] then
|
||||||
|
edited := True;
|
||||||
|
if Length(CellEditor.Caption) = 0 then
|
||||||
|
begin
|
||||||
|
if edited then
|
||||||
|
begin
|
||||||
|
Field.DataSet.Edit;
|
||||||
|
Field.Value := Null;
|
||||||
|
theValue := 0;
|
||||||
|
updated := True;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
if Length(CellEditor.Caption) <> 0 then
|
if Length(CellEditor.Caption) <> 0 then
|
||||||
if (Key in [VK_RETURN, VK_TAB, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT]) and
|
if (Key in [VK_RETURN, VK_TAB, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT]) and
|
||||||
(not IsValidDateString(NormalizeDate(CellEditor.Caption, theValue))) then
|
(not IsValidDateString(NormalizeDate(CellEditor.Caption, theValue))) then
|
||||||
|
Reference in New Issue
Block a user