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; property Columns: TJDBGridColumns read GetColumns write SetColumns;
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: integer); procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: integer);
override; 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; procedure KeyDown(var Key: word; Shift: TShiftState); override;
public public
{ Public declarations } { Public declarations }
@ -203,13 +205,35 @@ end;
procedure TJDBGridControl.MouseDown(Button: TMouseButton; Shift: TShiftState; procedure TJDBGridControl.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: integer); 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 begin
if not (integerDbGridControl.CanDefocus and doubleDbGridControl.CanDefocus and if not (integerDbGridControl.CanDefocus and doubleDbGridControl.CanDefocus and
dateTimeDbGridControl.CanDefocus and stringDbGridControl.CanDefocus and dateTimeDbGridControl.CanDefocus and stringDbGridControl.CanDefocus and
dateDbGridControl.CanDefocus and timeDbGridControl.CanDefocus) then dateDbGridControl.CanDefocus and timeDbGridControl.CanDefocus) then
abort abort
else 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; end;
procedure TJDBGridControl.KeyDown(var Key: word; Shift: TShiftState); procedure TJDBGridControl.KeyDown(var Key: word; Shift: TShiftState);

View File

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