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
|
||||
bTime: TDateTime;
|
||||
begin
|
||||
//if StrToDateDef(Value, MaxDateTime) = MaxDateTime then
|
||||
// Result := False
|
||||
//else
|
||||
// Result := True;
|
||||
Result:= TryStrToDate(Value, bTime);
|
||||
end;
|
||||
|
||||
|
@ -186,7 +186,7 @@ end;
|
||||
|
||||
procedure TJDBGridControl.UpdateData;
|
||||
begin
|
||||
if Editor is TJStringCellEditor then
|
||||
if not(Editor is TJStringCellEditor) then
|
||||
inherited UpdateData;
|
||||
end;
|
||||
|
||||
|
@ -341,6 +341,19 @@ end;
|
||||
procedure TJDbGridDateTimeCtrl.OnKeyDown(Sender: TObject; var Key: word;
|
||||
Shift: TShiftState);
|
||||
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 (Key in [VK_RETURN, VK_TAB, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT]) and
|
||||
(not IsValidDateTimeString(NormalizeDateTime(CellEditor.Caption, theValue))) then
|
||||
@ -488,12 +501,17 @@ end;
|
||||
procedure TJDbGridTimeCtrl.OnKeyDown(Sender: TObject; var Key: word;
|
||||
Shift: TShiftState);
|
||||
begin
|
||||
if Key in [VK_DELETE, VK_BACK] then
|
||||
edited := True;
|
||||
if Length(CellEditor.Caption) = 0 then
|
||||
begin
|
||||
Field.DataSet.Edit;
|
||||
Field.Value := Null;
|
||||
theValue := 0;
|
||||
updated := True;
|
||||
if edited then
|
||||
begin
|
||||
Field.DataSet.Edit;
|
||||
Field.Value := Null;
|
||||
theValue := 0;
|
||||
updated := True;
|
||||
end;
|
||||
end
|
||||
else
|
||||
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;
|
||||
Shift: TShiftState);
|
||||
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 (Key in [VK_RETURN, VK_TAB, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT]) and
|
||||
(not IsValidDateString(NormalizeDate(CellEditor.Caption, theValue))) then
|
||||
|
Reference in New Issue
Block a user