Manage MouseWheel events

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@3062 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
jujibo
2014-05-20 07:48:36 +00:00
parent cb9d07d0dd
commit b14de477c2
2 changed files with 43 additions and 8 deletions

View File

@ -78,6 +78,8 @@ type
property Columns: TJDBGridColumns read GetColumns write SetColumns;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: integer);
override;
function DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint): boolean; override;
function DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): boolean; override;
procedure KeyDown(var Key: word; Shift: TShiftState); override;
public
{ Public declarations }
@ -203,13 +205,35 @@ end;
procedure TJDBGridControl.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: integer);
begin
if (Button = mbLeft) and not (integerDbGridControl.CanDefocus and
doubleDbGridControl.CanDefocus and dateTimeDbGridControl.CanDefocus and
stringDbGridControl.CanDefocus and dateDbGridControl.CanDefocus and
timeDbGridControl.CanDefocus) then
abort
else
inherited MouseDown(Button, Shift, X, Y);
end;
function TJDBGridControl.DoMouseWheelDown(Shift: TShiftState;
MousePos: TPoint): boolean;
begin
if not (integerDbGridControl.CanDefocus and doubleDbGridControl.CanDefocus and
dateTimeDbGridControl.CanDefocus and stringDbGridControl.CanDefocus and
dateDbGridControl.CanDefocus and timeDbGridControl.CanDefocus) then
abort
else
inherited MouseDown(Button, Shift, X, Y);
Result := inherited DoMouseWheelDown(Shift, MousePos);
end;
function TJDBGridControl.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint): boolean;
begin
if not (integerDbGridControl.CanDefocus and doubleDbGridControl.CanDefocus and
dateTimeDbGridControl.CanDefocus and stringDbGridControl.CanDefocus and
dateDbGridControl.CanDefocus and timeDbGridControl.CanDefocus) then
abort
else
Result := inherited DoMouseWheelUp(Shift, MousePos);
end;
procedure TJDBGridControl.KeyDown(var Key: word; Shift: TShiftState);

View File

@ -293,6 +293,7 @@ end;
function TJDbGridStringCtrl.CanDefocus: boolean;
begin
Result := True;
myEditOnEditingDone(nil);
end;
{ TJDbGridDateTimeCtrl }
@ -530,7 +531,9 @@ begin
begin
ShowMessage(Format(SInvalidDateTime, [CellEditor.Text]));
CellEditor.Text := EditText;
end;
end
else
myEditOnEditingDone(nil);
end;
{ TJDbGridTimeCtrl }
@ -720,7 +723,9 @@ begin
begin
ShowMessage(Format(SInvalidTime, [CellEditor.Text]));
CellEditor.Text := Field.AsString;
end;
end
else
myEditOnEditingDone(nil);
end;
{ TJDbGridDateCtrl }
@ -949,7 +954,9 @@ begin
begin
ShowMessage(Format(SInvalidDate, [CellEditor.Text]));
CellEditor.Text := Field.AsString;
end;
end
else
myEditOnEditingDone(nil);
end;
{ TJDbGridDoubleCtrl }
@ -1123,7 +1130,9 @@ begin
CellEditor.Text := FormatFloat(fEFormat, Field.AsFloat)
else
CellEditor.Text := Field.AsString;
end;
end
else
myEditOnEditingDone(nil);
end;
{ TJDbGridIntegerCtrl }
@ -1255,7 +1264,9 @@ begin
begin
ShowMessage(Format(SInvalidNumber, [CellEditor.Text]));
CellEditor.Text := Field.AsString;
end;
end
else
myEditOnEditingDone(nil);
end;
end.